Package io.opentelemetry.sdk.trace
Class SdkTracerProvider
java.lang.Object
io.opentelemetry.sdk.trace.SdkTracerProvider
- All Implemented Interfaces:
TracerProvider
,Closeable
,AutoCloseable
SDK implementation for
TracerProvider
.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final String
private static final Logger
private final TracerSharedState
private final ScopeConfigurator
<TracerConfig> private final ComponentRegistry
<SdkTracer> -
Constructor Summary
ConstructorsConstructorDescriptionSdkTracerProvider
(Clock clock, IdGenerator idsGenerator, Resource resource, Supplier<SpanLimits> spanLimitsSupplier, Sampler sampler, List<SpanProcessor> spanProcessors, ScopeConfigurator<TracerConfig> tracerConfigurator) -
Method Summary
Modifier and TypeMethodDescriptionstatic SdkTracerProviderBuilder
builder()
Returns a newSdkTracerProviderBuilder
forSdkTracerProvider
.void
close()
Attempts to stop all the activity forTracer
s created by this provider.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.Gets or creates a named tracer instance.Gets or creates a named and versioned tracer instance.Returns the configuredSampler
.Returns theSpanLimits
that are currently applied to created spans.private TracerConfig
getTracerConfig
(InstrumentationScopeInfo instrumentationScopeInfo) shutdown()
Attempts to stop all the activity forTracer
s created by this provider.toString()
tracerBuilder
(String instrumentationScopeName) Creates a TracerBuilder for a namedTracer
instance.
-
Field Details
-
logger
-
DEFAULT_TRACER_NAME
- See Also:
-
tracerSdkComponentRegistry
-
tracerConfigurator
-
-
Constructor Details
-
SdkTracerProvider
SdkTracerProvider(Clock clock, IdGenerator idsGenerator, Resource resource, Supplier<SpanLimits> spanLimitsSupplier, Sampler sampler, List<SpanProcessor> spanProcessors, ScopeConfigurator<TracerConfig> tracerConfigurator)
-
-
Method Details
-
builder
Returns a newSdkTracerProviderBuilder
forSdkTracerProvider
.- Returns:
- a new
SdkTracerProviderBuilder
forSdkTracerProvider
.
-
getTracerConfig
-
get
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
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
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
Returns theSpanLimits
that are currently applied to created spans. -
getSampler
Returns the configuredSampler
. -
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
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:
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
toString
-