Class SampledSpanStore
- java.lang.Object
-
- io.opencensus.trace.export.SampledSpanStore
-
- Direct Known Subclasses:
SampledSpanStore.NoopSampledSpanStore
,SampledSpanStoreImpl
@ThreadSafe public abstract class SampledSpanStore extends java.lang.Object
This class allows users to access in-process information such as latency based sampled spans and error based sampled spans.For all completed spans with the option
Span.Options.RECORD_EVENTS
the library can store samples based on latency for succeeded operations or based on error code for failed operations. To activate this, users MUST manually configure all the span names for which samples will be collected (seeregisterSpanNamesForCollection(Collection)
).- Since:
- 0.5
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SampledSpanStore.ErrorFilter
Filter for error based sampled spans.static class
SampledSpanStore.LatencyBucketBoundaries
The latency buckets boundaries.static class
SampledSpanStore.LatencyFilter
Filter for latency based sampled spans.private static class
SampledSpanStore.NoopSampledSpanStore
static class
SampledSpanStore.PerSpanNameSummary
Summary of all available data for a span name.static class
SampledSpanStore.Summary
The summary of all available data.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SampledSpanStore()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.util.Collection<SpanData>
getErrorSampledSpans(SampledSpanStore.ErrorFilter filter)
abstract java.util.Collection<SpanData>
getLatencySampledSpans(SampledSpanStore.LatencyFilter filter)
abstract java.util.Set<java.lang.String>
getRegisteredSpanNamesForCollection()
Returns the set of unique span names registered to the library, for use in tests.abstract 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.(package private) static SampledSpanStore
newNoopSampledSpanStore()
Returns aSampledSpanStore
that maintains a set of span names, but always returns an empty list ofSpanData
.abstract void
registerSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Deprecated.since 0.18.abstract void
unregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Deprecated.since 0.18.
-
-
-
Method Detail
-
newNoopSampledSpanStore
static SampledSpanStore newNoopSampledSpanStore()
Returns aSampledSpanStore
that maintains a set of span names, but always returns an empty list ofSpanData
.- Returns:
- a
SampledSpanStore
that maintains a set of span names, but always returns an empty list ofSpanData
.
-
getSummary
public abstract 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.Data available only for span names registered using
registerSpanNamesForCollection(Collection)
.- Returns:
- the summary of all available data.
- Since:
- 0.5
-
getLatencySampledSpans
public abstract java.util.Collection<SpanData> getLatencySampledSpans(SampledSpanStore.LatencyFilter filter)
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
registerSpanNamesForCollection(Collection)
.- Parameters:
filter
- used to filter the returned sampled spans.- Returns:
- a list of succeeded spans that match the
filter
. - Since:
- 0.5
-
getErrorSampledSpans
public abstract java.util.Collection<SpanData> getErrorSampledSpans(SampledSpanStore.ErrorFilter filter)
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
registerSpanNamesForCollection(Collection)
.- Parameters:
filter
- used to filter the returned sampled spans.- Returns:
- a list of failed spans that match the
filter
. - Since:
- 0.5
-
registerSpanNamesForCollection
@Deprecated public abstract void registerSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Deprecated.since 0.18. UseEndSpanOptions.getSampleToLocalSpanStore()
.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.
- Parameters:
spanNames
- list of span names for which the library will collect samples.- Since:
- 0.5
-
unregisterSpanNamesForCollection
@Deprecated public abstract void unregisterSpanNamesForCollection(java.util.Collection<java.lang.String> spanNames)
Deprecated.since 0.18. The need of controlling the registration the span name will be removed soon.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.
- Parameters:
spanNames
- list of span names for which the library will no longer collect samples.- Since:
- 0.5
-
getRegisteredSpanNamesForCollection
public abstract java.util.Set<java.lang.String> getRegisteredSpanNamesForCollection()
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.
- Returns:
- the set of unique span names registered to the library.
- Since:
- 0.7
-
-