Class InProcessSampledSpanStoreImpl
- java.lang.Object
-
- io.opencensus.trace.export.SampledSpanStore
-
- io.opencensus.implcore.trace.export.SampledSpanStoreImpl
-
- io.opencensus.implcore.trace.export.InProcessSampledSpanStoreImpl
-
@ThreadSafe public final class InProcessSampledSpanStoreImpl extends SampledSpanStoreImpl
In-process implementation of theSampledSpanStore
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
InProcessSampledSpanStoreImpl.Bucket
private static class
InProcessSampledSpanStoreImpl.PerSpanNameSamples
Keeps samples for a given span name.private static class
InProcessSampledSpanStoreImpl.RegisterSpanNameEvent
private static class
InProcessSampledSpanStoreImpl.UnregisterSpanNameEvent
-
Nested classes/interfaces inherited from class io.opencensus.trace.export.SampledSpanStore
SampledSpanStore.ErrorFilter, SampledSpanStore.LatencyBucketBoundaries, SampledSpanStore.LatencyFilter, SampledSpanStore.PerSpanNameSummary, SampledSpanStore.Summary
-
-
Field Summary
Fields Modifier and Type Field Description private EventQueue
eventQueue
private static int
MAX_PER_SPAN_NAME_SAMPLES
private static int
NUM_ERROR_BUCKETS
private static int
NUM_LATENCY_BUCKETS
private static int
NUM_SAMPLES_PER_ERROR_BUCKET
private static int
NUM_SAMPLES_PER_LATENCY_BUCKET
private java.util.Map<java.lang.String,InProcessSampledSpanStoreImpl.PerSpanNameSamples>
samples
private static long
TIME_BETWEEN_SAMPLES
-
Constructor Summary
Constructors Constructor Description InProcessSampledSpanStoreImpl(EventQueue eventQueue)
Constructs a newInProcessSampledSpanStoreImpl
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
considerForSampling(RecordEventsSpanImpl span)
Considers to save the given spans to the stored samples.boolean
getEnabled()
Returnstrue
if the SampledSpanStore is enabled.java.util.Collection<SpanData>
getErrorSampledSpans(SampledSpanStore.ErrorFilter filter)
java.util.Collection<SpanData>
getLatencySampledSpans(SampledSpanStore.LatencyFilter filter)
java.util.Set<java.lang.String>
getRegisteredSpanNamesForCollection()
Returns the set of unique span names registered to the library, for use in tests.SampledSpanStore.Summary
getSummary()
Returns the summary of all available data, such as number of sampled spans in the latency based samples or error based samples.private void
internaltRegisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
private void
internalUnregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
void
registerSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Appends a list of span names for which the library will collect latency based sampled spans and error based sampled spans.protected void
shutdown()
void
unregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Removes a list of span names for which the library will collect latency based sampled spans and error based sampled spans.-
Methods inherited from class io.opencensus.implcore.trace.export.SampledSpanStoreImpl
getNoopSampledSpanStoreImpl
-
-
-
-
Field Detail
-
NUM_SAMPLES_PER_LATENCY_BUCKET
private static final int NUM_SAMPLES_PER_LATENCY_BUCKET
- See Also:
- Constant Field Values
-
NUM_SAMPLES_PER_ERROR_BUCKET
private static final int NUM_SAMPLES_PER_ERROR_BUCKET
- See Also:
- Constant Field Values
-
TIME_BETWEEN_SAMPLES
private static final long TIME_BETWEEN_SAMPLES
-
NUM_LATENCY_BUCKETS
private static final int NUM_LATENCY_BUCKETS
-
NUM_ERROR_BUCKETS
private static final int NUM_ERROR_BUCKETS
-
MAX_PER_SPAN_NAME_SAMPLES
private static final int MAX_PER_SPAN_NAME_SAMPLES
-
eventQueue
private final EventQueue eventQueue
-
samples
private final java.util.Map<java.lang.String,InProcessSampledSpanStoreImpl.PerSpanNameSamples> samples
-
-
Constructor Detail
-
InProcessSampledSpanStoreImpl
InProcessSampledSpanStoreImpl(EventQueue eventQueue)
Constructs a newInProcessSampledSpanStoreImpl
.
-
-
Method Detail
-
getSummary
public SampledSpanStore.Summary getSummary()
Description copied from class:SampledSpanStore
Returns the summary of all available data, such as number of sampled spans in the latency based samples or error based samples.Data available only for span names registered using
SampledSpanStore.registerSpanNamesForCollection(Collection)
.- Specified by:
getSummary
in classSampledSpanStore
- Returns:
- the summary of all available data.
-
considerForSampling
public void considerForSampling(RecordEventsSpanImpl span)
Description copied from class:SampledSpanStoreImpl
Considers to save the given spans to the stored samples. This must be called at the end of each Span with the option RECORD_EVENTS.- Specified by:
considerForSampling
in classSampledSpanStoreImpl
- Parameters:
span
- the span to be consider for storing into the store buckets.
-
getEnabled
public boolean getEnabled()
Description copied from class:SampledSpanStoreImpl
Returnstrue
if the SampledSpanStore is enabled.- Specified by:
getEnabled
in classSampledSpanStoreImpl
- Returns:
true
if the SampledSpanStore is enabled.
-
registerSpanNamesForCollection
public void registerSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Description copied from class:SampledSpanStore
Appends a list of span names for which the library will collect latency based sampled spans and error based sampled spans.If called multiple times the library keeps the list of unique span names from all the calls.
- Specified by:
registerSpanNamesForCollection
in classSampledSpanStore
- Parameters:
spanNames
- list of span names for which the library will collect samples.
-
shutdown
protected void shutdown()
- Overrides:
shutdown
in classSampledSpanStoreImpl
-
internaltRegisterSpanNamesForCollection
private void internaltRegisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
-
unregisterSpanNamesForCollection
public void unregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Description copied from class:SampledSpanStore
Removes a list of span names for which the library will collect latency based sampled spans and error based sampled spans.The library keeps the list of unique registered span names for which samples will be called. This method allows users to remove span names from that list.
- Specified by:
unregisterSpanNamesForCollection
in classSampledSpanStore
- Parameters:
spanNames
- list of span names for which the library will no longer collect samples.
-
internalUnregisterSpanNamesForCollection
private void internalUnregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
-
getRegisteredSpanNamesForCollection
public java.util.Set<java.lang.String> getRegisteredSpanNamesForCollection()
Description copied from class:SampledSpanStore
Returns the set of unique span names registered to the library, for use in tests. For this set of span names the library will collect latency based sampled spans and error based sampled spans.This method is only meant for testing code that uses OpenCensus, and it is not performant.
- Specified by:
getRegisteredSpanNamesForCollection
in classSampledSpanStore
- Returns:
- the set of unique span names registered to the library.
-
getErrorSampledSpans
public java.util.Collection<SpanData> getErrorSampledSpans(SampledSpanStore.ErrorFilter filter)
Description copied from class:SampledSpanStore
Returns a list of failed spans (spans withStatus
other thanStatus.OK
) that match thefilter
.Error based sampled spans are available only for span names registered using
SampledSpanStore.registerSpanNamesForCollection(Collection)
.- Specified by:
getErrorSampledSpans
in classSampledSpanStore
- Parameters:
filter
- used to filter the returned sampled spans.- Returns:
- a list of failed spans that match the
filter
.
-
getLatencySampledSpans
public java.util.Collection<SpanData> getLatencySampledSpans(SampledSpanStore.LatencyFilter filter)
Description copied from class:SampledSpanStore
Returns a list of succeeded spans (spans withStatus
equal toStatus.OK
) that match thefilter
.Latency based sampled spans are available only for span names registered using
SampledSpanStore.registerSpanNamesForCollection(Collection)
.- Specified by:
getLatencySampledSpans
in classSampledSpanStore
- Parameters:
filter
- used to filter the returned sampled spans.- Returns:
- a list of succeeded spans that match the
filter
.
-
-