Class SdkTracerProvider

java.lang.Object
io.opentelemetry.sdk.trace.SdkTracerProvider
All Implemented Interfaces:
TracerProvider, Closeable, AutoCloseable

public final class SdkTracerProvider extends Object implements TracerProvider, Closeable
SDK implementation for TracerProvider.
  • Field Details

  • Constructor Details

  • Method Details

    • builder

      public static SdkTracerProviderBuilder builder()
      Returns:
      a new SdkTracerProviderBuilder for SdkTracerProvider.
    • getTracerConfig

      private TracerConfig getTracerConfig(InstrumentationScopeInfo instrumentationScopeInfo)
    • get

      public Tracer get(String instrumentationScopeName)
      Description copied from interface: TracerProvider
      Gets or creates a named tracer instance.
      Specified by:
      get in interface TracerProvider
      Parameters:
      instrumentationScopeName - A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.
      Returns:
      a tracer instance.
    • get

      public Tracer get(String instrumentationScopeName, String instrumentationScopeVersion)
      Description copied from interface: TracerProvider
      Gets or creates a named and versioned tracer instance.
      Specified by:
      get in interface TracerProvider
      Parameters:
      instrumentationScopeName - A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.
      instrumentationScopeVersion - The version of the instrumentation scope (e.g., "1.0.0").
      Returns:
      a tracer instance.
    • tracerBuilder

      public TracerBuilder tracerBuilder(@Nullable String instrumentationScopeName)
      Description copied from interface: TracerProvider
      Creates a TracerBuilder for a named Tracer instance.
      Specified by:
      tracerBuilder in interface TracerProvider
      Parameters:
      instrumentationScopeName - A name uniquely identifying the instrumentation scope, such as the instrumentation library, package, or fully qualified class name. Must not be null.
      Returns:
      a TracerBuilder instance.
    • getSpanLimits

      public SpanLimits getSpanLimits()
      Returns the SpanLimits that are currently applied to created spans.
    • getSampler

      public Sampler getSampler()
      Returns the configured Sampler.
    • shutdown

      public CompletableResultCode shutdown()
      Attempts to stop all the activity for Tracers created by this provider. Calls SpanProcessor.shutdown() for all registered SpanProcessors.

      The returned CompletableResultCode will be completed when all the Spans are processed.

      After this is called, newly created Spans will be no-ops.

      After this is called, further attempts at re-using this instance will result in undefined behavior. It should be considered a terminal operation for the SDK.

      Returns:
      a CompletableResultCode which is completed when all the span processors have been shut down.
    • forceFlush

      public CompletableResultCode forceFlush()
      Requests the active span processor to process all span events that have not yet been processed and returns a CompletableResultCode which is completed when the flush is finished.
      See Also:
    • close

      public void close()
      Attempts to stop all the activity for Tracers created by this provider. Calls SpanProcessor.shutdown() for all registered SpanProcessors.

      This operation may block until all the Spans are processed. Must be called before turning off the main application to ensure all data are processed and exported.

      After this is called, newly created Spans will be no-ops.

      After this is called, further attempts at re-using this instance will result in undefined behavior. It should be considered a terminal operation for the SDK.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • toString

      public String toString()
      Overrides:
      toString in class Object