Class InstrumenterBuilder<REQUEST,RESPONSE>
java.lang.Object
io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder<REQUEST,RESPONSE>
A builder of an
Instrumenter
.
Instrumentation libraries should generally expose their own builder with controls that are
appropriate for that library and delegate to this class to create the Instrumenter
.
-
Method Summary
Modifier and TypeMethodDescriptionaddAttributesExtractor
(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractor
that will extract attributes from requests and responses.addAttributesExtractors
(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractor
s that will extract attributes from requests and responses.addContextCustomizer
(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizer
that will customize the context duringInstrumenter.start(Context, Object)
.addOperationListener
(OperationListener listener) Adds aOperationListener
that will be called when an instrumented operation starts and ends.addOperationMetrics
(OperationMetrics factory) Adds aOperationMetrics
that will produce aOperationListener
capturing the requests processing metrics.addSpanLinksExtractor
(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractor
that will extract span links from requests.buildClientInstrumenter
(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenter
which will create client spans and inject context into requests.buildConsumerInstrumenter
(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenter
which will create consumer spans and extract context from requests.Returns a newInstrumenter
which will create internal spans and do no context propagation.buildInstrumenter
(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenter
which will create spans with kind determined by the passedSpanKindExtractor
and do no context propagation.buildProducerInstrumenter
(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenter
which will create producer spans and inject context into requests.buildServerInstrumenter
(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenter
which will create server spans and extract context from requests.setEnabled
(boolean enabled) Allows enabling/disabling theInstrumenter
based on theenabled
value passed as parameter.setErrorCauseExtractor
(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractor
that will extract the root cause of an error thrown during request processing.setInstrumentationVersion
(String instrumentationVersion) Sets the instrumentation version that will be associated with all telemetry produced by thisInstrumenter
.setSchemaUrl
(String schemaUrl) Sets the OpenTelemetry schema URL that will be associated with all telemetry produced by thisInstrumenter
.setSpanStatusExtractor
(SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor) Sets theSpanStatusExtractor
that will determine theStatusCode
for a response.
-
Method Details
-
setInstrumentationVersion
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> setInstrumentationVersion(String instrumentationVersion) Sets the instrumentation version that will be associated with all telemetry produced by thisInstrumenter
.- Parameters:
instrumentationVersion
- is the version of the instrumentation library, not the version of the instrumented library.
-
setSchemaUrl
Sets the OpenTelemetry schema URL that will be associated with all telemetry produced by thisInstrumenter
. -
setSpanStatusExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> setSpanStatusExtractor(SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor) Sets theSpanStatusExtractor
that will determine theStatusCode
for a response. -
addAttributesExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractor(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractor
that will extract attributes from requests and responses. -
addAttributesExtractors
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractor
s that will extract attributes from requests and responses. -
addSpanLinksExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractor
that will extract span links from requests. -
addContextCustomizer
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizer
that will customize the context duringInstrumenter.start(Context, Object)
. -
addOperationListener
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addOperationListener(OperationListener listener) Adds aOperationListener
that will be called when an instrumented operation starts and ends. -
addOperationMetrics
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addOperationMetrics(OperationMetrics factory) Adds aOperationMetrics
that will produce aOperationListener
capturing the requests processing metrics. -
setErrorCauseExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractor
that will extract the root cause of an error thrown during request processing. -
setEnabled
Allows enabling/disabling theInstrumenter
based on theenabled
value passed as parameter. All instrumenters are enabled by default. -
buildClientInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenter
which will create client spans and inject context into requests. -
buildServerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildServerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenter
which will create server spans and extract context from requests. -
buildProducerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenter
which will create producer spans and inject context into requests. -
buildConsumerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildConsumerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenter
which will create consumer spans and extract context from requests. -
buildInstrumenter
Returns a newInstrumenter
which will create internal spans and do no context propagation. -
buildInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenter
which will create spans with kind determined by the passedSpanKindExtractor
and do no context propagation.
-