Class SdkTracerProviderBuilder
- java.lang.Object
-
- io.opentelemetry.sdk.trace.SdkTracerProviderBuilder
-
public final class SdkTracerProviderBuilder extends java.lang.Object
Builder ofSdkTracerProvider
.
-
-
Field Summary
Fields Modifier and Type Field Description private Clock
clock
private static Sampler
DEFAULT_SAMPLER
private IdGenerator
idsGenerator
private Resource
resource
private Sampler
sampler
private java.util.function.Supplier<SpanLimits>
spanLimitsSupplier
private java.util.List<SpanProcessor>
spanProcessors
private ScopeConfiguratorBuilder<TracerConfig>
tracerConfiguratorBuilder
-
Constructor Summary
Constructors Constructor Description SdkTracerProviderBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SdkTracerProviderBuilder
addResource(Resource resource)
Merge aResource
with the current.SdkTracerProviderBuilder
addSpanProcessor(SpanProcessor spanProcessor)
Add a SpanProcessor to the span pipeline that will be built.(package private) SdkTracerProviderBuilder
addTracerConfiguratorCondition(java.util.function.Predicate<InstrumentationScopeInfo> scopeMatcher, TracerConfig tracerConfig)
Adds a condition to the tracer configurator, which computesTracerConfig
for eachInstrumentationScopeInfo
.SdkTracerProvider
build()
Create a newSdkTracerProvider
instance with the configuration.SdkTracerProviderBuilder
setClock(Clock clock)
Assign aClock
.SdkTracerProviderBuilder
setIdGenerator(IdGenerator idGenerator)
Assign anIdGenerator
.SdkTracerProviderBuilder
setResource(Resource resource)
Assign aResource
to be attached to all Spans created by Tracers.SdkTracerProviderBuilder
setSampler(Sampler sampler)
Assign aSampler
to use for sampling traces.SdkTracerProviderBuilder
setSpanLimits(SpanLimits spanLimits)
Assign an initialSpanLimits
that should be used with this SDK.SdkTracerProviderBuilder
setSpanLimits(java.util.function.Supplier<SpanLimits> spanLimitsSupplier)
Assign aSupplier
ofSpanLimits
.(package private) SdkTracerProviderBuilder
setTracerConfigurator(ScopeConfigurator<TracerConfig> tracerConfigurator)
Set the tracer configurator, which computesTracerConfig
for eachInstrumentationScopeInfo
.
-
-
-
Field Detail
-
DEFAULT_SAMPLER
private static final Sampler DEFAULT_SAMPLER
-
spanProcessors
private final java.util.List<SpanProcessor> spanProcessors
-
clock
private Clock clock
-
idsGenerator
private IdGenerator idsGenerator
-
resource
private Resource resource
-
spanLimitsSupplier
private java.util.function.Supplier<SpanLimits> spanLimitsSupplier
-
sampler
private Sampler sampler
-
tracerConfiguratorBuilder
private ScopeConfiguratorBuilder<TracerConfig> tracerConfiguratorBuilder
-
-
Method Detail
-
setClock
public SdkTracerProviderBuilder setClock(Clock clock)
Assign aClock
.Clock
will be used each time aSpan
is started, ended or any event is recorded.The
clock
must be thread-safe and return immediately (no remote calls, as contention free as possible).- Parameters:
clock
- The clock to use for all temporal needs.- Returns:
- this
-
setIdGenerator
public SdkTracerProviderBuilder setIdGenerator(IdGenerator idGenerator)
Assign anIdGenerator
.IdGenerator
will be used each time aSpan
is started.The
idGenerator
must be thread-safe and return immediately (no remote calls, as contention free as possible).- Parameters:
idGenerator
- A generator for trace and span ids.- Returns:
- this
-
setResource
public SdkTracerProviderBuilder setResource(Resource resource)
Assign aResource
to be attached to all Spans created by Tracers.- Parameters:
resource
- A Resource implementation.- Returns:
- this
-
addResource
public SdkTracerProviderBuilder addResource(Resource resource)
Merge aResource
with the current.- Parameters:
resource
-Resource
to merge with current.- Since:
- 1.29.0
-
setSpanLimits
public SdkTracerProviderBuilder setSpanLimits(SpanLimits spanLimits)
Assign an initialSpanLimits
that should be used with this SDK.This method is equivalent to calling
setSpanLimits(Supplier)
like this#setSpanLimits(() -> spanLimits)
.- Parameters:
spanLimits
- the limits that will be used for everySpan
.- Returns:
- this
-
setSpanLimits
public SdkTracerProviderBuilder setSpanLimits(java.util.function.Supplier<SpanLimits> spanLimitsSupplier)
Assign aSupplier
ofSpanLimits
.SpanLimits
will be retrieved each time aSpan
is started.The
spanLimitsSupplier
must be thread-safe and return immediately (no remote calls, as contention free as possible).- Parameters:
spanLimitsSupplier
- the supplier that will be used to retrieve theSpanLimits
for everySpan
.- Returns:
- this
-
setSampler
public SdkTracerProviderBuilder setSampler(Sampler sampler)
Assign aSampler
to use for sampling traces.Sampler
will be called each time aSpan
is started.The
sampler
must be thread-safe and return immediately (no remote calls, as contention free as possible).- Parameters:
sampler
- theSampler
to use for sampling traces.- Returns:
- this
-
addSpanProcessor
public SdkTracerProviderBuilder addSpanProcessor(SpanProcessor spanProcessor)
Add a SpanProcessor to the span pipeline that will be built.SpanProcessor
will be called each time aSpan
is started or ended.The
spanProcessor
must be thread-safe and return immediately (no remote calls, as contention free as possible).- Parameters:
spanProcessor
- the processor to be added to the processing pipeline.- Returns:
- this
-
setTracerConfigurator
SdkTracerProviderBuilder setTracerConfigurator(ScopeConfigurator<TracerConfig> tracerConfigurator)
Set the tracer configurator, which computesTracerConfig
for eachInstrumentationScopeInfo
.This method is experimental so not public. You may reflectively call it using
SdkTracerProviderUtil.setTracerConfigurator(SdkTracerProviderBuilder, ScopeConfigurator)
.Overrides any matchers added via
addTracerConfiguratorCondition(Predicate, TracerConfig)
.- See Also:
TracerConfig.configuratorBuilder()
-
addTracerConfiguratorCondition
SdkTracerProviderBuilder addTracerConfiguratorCondition(java.util.function.Predicate<InstrumentationScopeInfo> scopeMatcher, TracerConfig tracerConfig)
Adds a condition to the tracer configurator, which computesTracerConfig
for eachInstrumentationScopeInfo
.This method is experimental so not public. You may reflectively call it using
SdkTracerProviderUtil.addTracerConfiguratorCondition(SdkTracerProviderBuilder, Predicate, TracerConfig)
.Applies after any previously added conditions.
If
setTracerConfigurator(ScopeConfigurator)
was previously called, this condition will only be applied if theFunction.apply(Object)
returns null for the matchedInstrumentationScopeInfo
(s).
-
build
public SdkTracerProvider build()
Create a newSdkTracerProvider
instance with the configuration.- Returns:
- The instance.
-
-