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 aAttributesExtractorthat will extract attributes from requests and responses.addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractors that will extract attributes from requests and responses.addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizerthat will customize the context duringInstrumenter.start(Context, Object).addOperationListener(OperationListener listener) Adds aOperationListenerthat will be called when an instrumented operation starts and ends.addOperationMetrics(OperationMetrics factory) Adds aOperationMetricsthat will produce aOperationListenercapturing the requests processing metrics.addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractorthat will extract span links from requests.buildClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create client spans and inject context into requests.buildConsumerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create consumer spans and extract context from requests.Returns a newInstrumenterwhich will create internal spans and do no context propagation.buildInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenterwhich will create spans with kind determined by the passedSpanKindExtractorand do no context propagation.buildProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create producer spans and inject context into requests.buildServerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create server spans and extract context from requests.setEnabled(boolean enabled) Allows enabling/disabling theInstrumenterbased on theenabledvalue passed as parameter.setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractorthat 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 theSpanStatusExtractorthat will determine theStatusCodefor 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 theSpanStatusExtractorthat will determine theStatusCodefor a response. -
addAttributesExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractor(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractorthat will extract attributes from requests and responses. -
addAttributesExtractors
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractors that will extract attributes from requests and responses. -
addSpanLinksExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractorthat will extract span links from requests. -
addContextCustomizer
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizerthat will customize the context duringInstrumenter.start(Context, Object). -
addOperationListener
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addOperationListener(OperationListener listener) Adds aOperationListenerthat will be called when an instrumented operation starts and ends. -
addOperationMetrics
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> addOperationMetrics(OperationMetrics factory) Adds aOperationMetricsthat will produce aOperationListenercapturing the requests processing metrics. -
setErrorCauseExtractor
@CanIgnoreReturnValue public InstrumenterBuilder<REQUEST,RESPONSE> setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractorthat will extract the root cause of an error thrown during request processing. -
setEnabled
Allows enabling/disabling theInstrumenterbased on theenabledvalue passed as parameter. All instrumenters are enabled by default. -
buildClientInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create client spans and inject context into requests. -
buildServerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildServerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create server spans and extract context from requests. -
buildProducerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create producer spans and inject context into requests. -
buildConsumerInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildConsumerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create consumer spans and extract context from requests. -
buildInstrumenter
Returns a newInstrumenterwhich will create internal spans and do no context propagation. -
buildInstrumenter
public Instrumenter<REQUEST,RESPONSE> buildInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenterwhich will create spans with kind determined by the passedSpanKindExtractorand do no context propagation.
-