Class 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 (see registerSpanNamesForCollection(Collection)).

    Since:
    0.5
    • Constructor Detail

      • SampledSpanStore

        protected SampledSpanStore()
    • Method Detail

      • newNoopSampledSpanStore

        static SampledSpanStore newNoopSampledSpanStore()
        Returns a SampledSpanStore that maintains a set of span names, but always returns an empty list of SpanData.
        Returns:
        a SampledSpanStore that maintains a set of span names, but always returns an empty list of SpanData.
      • 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 with Status equal to Status.OK) that match the filter.

        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 with Status other than Status.OK) that match the filter.

        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.
        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