Class InstrumenterBuilder<REQUEST,RESPONSE>
java.lang.Object
io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder<REQUEST,RESPONSE>
A builder of
Instrumenter. Instrumentation libraries should generally expose their own
builder with controls that are appropriate for that library and delegate to this to create the
Instrumenter.-
Method Summary
Modifier and TypeMethodDescriptionaddAttributesExtractor(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractorto extract attributes from requests and responses.final InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(AttributesExtractor<? super REQUEST, ? super RESPONSE>... attributesExtractors) AddsAttributesExtractors to extract attributes from requests and responses.addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractors to extract attributes from requests and responses.addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizerto customize the context duringInstrumenter.start(Context, Object).addRequestListener(RequestListener listener) Adds aRequestListenerwhich will be called for request start and end.addRequestMetrics(RequestMetrics factory) Adds aRequestMetricswhose metrics will be recorded for request start and end.addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractorto 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.setDisabled(boolean disabled) Deprecated.setEnabled(boolean enabled) Allows enabling/disabling theInstrumenterbased on theenabledvalue passed as parameter.setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractorto extract the root cause from an exception handling the request.setInstrumentationVersion(String instrumentationVersion) Sets the instrumentation version that'll be associated with all telemetry produced by thisInstrumenter.setSchemaUrl(String schemaUrl) Sets the OpenTelemetry schema URL that'll be associated with all telemetry produced by thisInstrumenter.setSpanStatusExtractor(SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor) Sets theSpanStatusExtractorto use to determine theStatusCodefor a response.setTimeExtractor(TimeExtractor<REQUEST, RESPONSE> timeExtractor) Sets theTimeExtractorto extract the timestamp marking the start and end of processing.
-
Method Details
-
setInstrumentationVersion
public InstrumenterBuilder<REQUEST,RESPONSE> setInstrumentationVersion(String instrumentationVersion) Sets the instrumentation version that'll be associated with all telemetry produced by thisInstrumenter.- Parameters:
instrumentationVersion- is the version of the instrumentation library, not the version of the instrument*ed* library.
-
setSchemaUrl
Sets the OpenTelemetry schema URL that'll be associated with all telemetry produced by thisInstrumenter. -
setSpanStatusExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> setSpanStatusExtractor(SpanStatusExtractor<? super REQUEST, ? super RESPONSE> spanStatusExtractor) Sets theSpanStatusExtractorto use to determine theStatusCodefor a response. -
addAttributesExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractor(AttributesExtractor<? super REQUEST, ? super RESPONSE> attributesExtractor) Adds aAttributesExtractorto extract attributes from requests and responses. -
addAttributesExtractors
public InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST, ? super RESPONSE>> attributesExtractors) AddsAttributesExtractors to extract attributes from requests and responses. -
addAttributesExtractors
@SafeVarargs public final InstrumenterBuilder<REQUEST,RESPONSE> addAttributesExtractors(AttributesExtractor<? super REQUEST, ? super RESPONSE>... attributesExtractors) AddsAttributesExtractors to extract attributes from requests and responses. -
addSpanLinksExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor) Adds aSpanLinksExtractorto extract span links from requests. -
addContextCustomizer
public InstrumenterBuilder<REQUEST,RESPONSE> addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer) Adds aContextCustomizerto customize the context duringInstrumenter.start(Context, Object). -
addRequestListener
Adds aRequestListenerwhich will be called for request start and end. -
addRequestMetrics
Adds aRequestMetricswhose metrics will be recorded for request start and end. -
setErrorCauseExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor) Sets theErrorCauseExtractorto extract the root cause from an exception handling the request. -
setTimeExtractor
public InstrumenterBuilder<REQUEST,RESPONSE> setTimeExtractor(TimeExtractor<REQUEST, RESPONSE> timeExtractor) Sets theTimeExtractorto extract the timestamp marking the start and end of processing. If unset, the constructed instrumenter will defer determining start and end timestamps to the OpenTelemetry SDK.Note: if metrics are generated by the Instrumenter, the start and end times from the
TimeExtractorwill be used to generate any duration metrics, but the internal metric timestamp (when it occurred) will always be stamped with "now" when the metric is recorded (i.e. there is no way to back date a metric recording). -
setEnabled
Allows enabling/disabling theInstrumenterbased on theenabledvalue passed as parameter. All instrumenters are enabled by default. -
setDisabled
Deprecated.UsesetEnabled(boolean)instead.Allows to disable theInstrumenter. -
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.
-
setEnabled(boolean)instead.