Package io.opentelemetry.sdk.trace
Class SdkTracerProvider
- java.lang.Object
-
- io.opentelemetry.sdk.trace.SdkTracerProvider
-
- All Implemented Interfaces:
TracerProvider
,java.io.Closeable
,java.lang.AutoCloseable
public final class SdkTracerProvider extends java.lang.Object implements TracerProvider, java.io.Closeable
SDK implementation forTracerProvider
.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
DEFAULT_TRACER_NAME
private static java.util.logging.Logger
logger
private TracerSharedState
sharedState
private ScopeConfigurator<TracerConfig>
tracerConfigurator
private ComponentRegistry<SdkTracer>
tracerSdkComponentRegistry
-
Constructor Summary
Constructors Constructor Description SdkTracerProvider(Clock clock, IdGenerator idsGenerator, Resource resource, java.util.function.Supplier<SpanLimits> spanLimitsSupplier, Sampler sampler, java.util.List<SpanProcessor> spanProcessors, ScopeConfigurator<TracerConfig> tracerConfigurator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SdkTracerProviderBuilder
builder()
Returns a newSdkTracerProviderBuilder
forSdkTracerProvider
.void
close()
Attempts to stop all the activity forTracer
s created by this provider.CompletableResultCode
forceFlush()
Requests the active span processor to process all span events that have not yet been processed and returns aCompletableResultCode
which is completed when the flush is finished.Tracer
get(java.lang.String instrumentationScopeName)
Gets or creates a named tracer instance.Tracer
get(java.lang.String instrumentationScopeName, java.lang.String instrumentationScopeVersion)
Gets or creates a named and versioned tracer instance.Sampler
getSampler()
Returns the configuredSampler
.SpanLimits
getSpanLimits()
Returns theSpanLimits
that are currently applied to created spans.private TracerConfig
getTracerConfig(InstrumentationScopeInfo instrumentationScopeInfo)
CompletableResultCode
shutdown()
Attempts to stop all the activity forTracer
s created by this provider.java.lang.String
toString()
TracerBuilder
tracerBuilder(java.lang.String instrumentationScopeName)
Creates a TracerBuilder for a namedTracer
instance.
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
DEFAULT_TRACER_NAME
static final java.lang.String DEFAULT_TRACER_NAME
- See Also:
- Constant Field Values
-
sharedState
private final TracerSharedState sharedState
-
tracerSdkComponentRegistry
private final ComponentRegistry<SdkTracer> tracerSdkComponentRegistry
-
tracerConfigurator
private final ScopeConfigurator<TracerConfig> tracerConfigurator
-
-
Constructor Detail
-
SdkTracerProvider
SdkTracerProvider(Clock clock, IdGenerator idsGenerator, Resource resource, java.util.function.Supplier<SpanLimits> spanLimitsSupplier, Sampler sampler, java.util.List<SpanProcessor> spanProcessors, ScopeConfigurator<TracerConfig> tracerConfigurator)
-
-
Method Detail
-
builder
public static SdkTracerProviderBuilder builder()
Returns a newSdkTracerProviderBuilder
forSdkTracerProvider
.- Returns:
- a new
SdkTracerProviderBuilder
forSdkTracerProvider
.
-
getTracerConfig
private TracerConfig getTracerConfig(InstrumentationScopeInfo instrumentationScopeInfo)
-
get
public Tracer get(java.lang.String instrumentationScopeName)
Description copied from interface:TracerProvider
Gets or creates a named tracer instance.- Specified by:
get
in interfaceTracerProvider
- 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(java.lang.String instrumentationScopeName, java.lang.String instrumentationScopeVersion)
Description copied from interface:TracerProvider
Gets or creates a named and versioned tracer instance.- Specified by:
get
in interfaceTracerProvider
- 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 java.lang.String instrumentationScopeName)
Description copied from interface:TracerProvider
Creates a TracerBuilder for a namedTracer
instance.- Specified by:
tracerBuilder
in interfaceTracerProvider
- 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 theSpanLimits
that are currently applied to created spans.
-
shutdown
public CompletableResultCode shutdown()
Attempts to stop all the activity forTracer
s created by this provider. CallsSpanProcessor.shutdown()
for all registeredSpanProcessor
s.The returned
CompletableResultCode
will be completed when all the Spans are processed.After this is called, newly created
Span
s 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 aCompletableResultCode
which is completed when the flush is finished.- See Also:
SpanProcessor.forceFlush()
-
close
public void close()
Attempts to stop all the activity forTracer
s created by this provider. CallsSpanProcessor.shutdown()
for all registeredSpanProcessor
s.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
Span
s 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-