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.final InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(AttributesExtractor<? super REQUEST, ? super RESPONSE>... attributesExtractors) AddsAttributesExtractors that 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.newClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create client spans and inject context into requests.newConsumerInstrumenter(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.newInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenterwhich will create spans with kind determined by the passedSpanKindExtractorand do no context propagation.newProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create producer spans and inject context into requests.newServerInstrumenter(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
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
public InstrumenterBuilder<REQUEST,RESPONSE> setSpanStatusExtractor(SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor) Sets theSpanStatusExtractorthat will determine theStatusCodefor a response. -
addAttributesExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractor(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractorthat will extract attributes from requests and responses. -
addAttributesExtractors
public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractors that will extract attributes from requests and responses. -
addAttributesExtractors
@SafeVarargs public final InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(AttributesExtractor<? super REQUEST, ? super RESPONSE>... attributesExtractors) AddsAttributesExtractors that will extract attributes from requests and responses. -
addSpanLinksExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractorthat will extract span links from requests. -
addContextCustomizer
public InstrumenterBuilder<REQUEST,RESPONSE> addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizerthat will customize the context duringInstrumenter.start(Context, Object). -
addOperationListener
Adds aOperationListenerthat will be called when an instrumented operation starts and ends. -
addOperationMetrics
Adds aOperationMetricsthat will produce aOperationListenercapturing the requests processing metrics. -
setErrorCauseExtractor
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. -
newClientInstrumenter
public Instrumenter<REQUEST,RESPONSE> newClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create client spans and inject context into requests. -
newServerInstrumenter
public Instrumenter<REQUEST,RESPONSE> newServerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create server spans and extract context from requests. -
newProducerInstrumenter
public Instrumenter<REQUEST,RESPONSE> newProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter) Returns a newInstrumenterwhich will create producer spans and inject context into requests. -
newConsumerInstrumenter
public Instrumenter<REQUEST,RESPONSE> newConsumerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter) Returns a newInstrumenterwhich will create consumer spans and extract context from requests. -
newInstrumenter
Returns a newInstrumenterwhich will create internal spans and do no context propagation. -
newInstrumenter
public Instrumenter<REQUEST,RESPONSE> newInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor) Returns a newInstrumenterwhich will create spans with kind determined by the passedSpanKindExtractorand do no context propagation.
-