Class InstrumenterBuilder<REQUEST,RESPONSE>
- java.lang.Object
-
- io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder<REQUEST,RESPONSE>
-
public final class InstrumenterBuilder<REQUEST,RESPONSE> extends Object
A builder ofInstrumenter. Instrumentation libraries should generally expose their own builder with controls that are appropriate for that library and delegate to this to create theInstrumenter.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstrumenterBuilder<REQUEST,RESPONSE>addAttributesExtractor(AttributesExtractor<? super REQUEST,? super RESPONSE> attributesExtractor)Adds aAttributesExtractorto extract attributes from requests and responses.InstrumenterBuilder<REQUEST,RESPONSE>addAttributesExtractors(AttributesExtractor<? super REQUEST,? super RESPONSE>... attributesExtractors)AddsAttributesExtractors to extract attributes from requests and responses.InstrumenterBuilder<REQUEST,RESPONSE>addAttributesExtractors(Iterable<? extends AttributesExtractor<? super REQUEST,? super RESPONSE>> attributesExtractors)AddsAttributesExtractors to extract attributes from requests and responses.InstrumenterBuilder<REQUEST,RESPONSE>addContextCustomizer(ContextCustomizer<? super REQUEST> contextCustomizer)Adds aContextCustomizerto customize the context duringInstrumenter.start(Context, Object).InstrumenterBuilder<REQUEST,RESPONSE>addRequestMetrics(RequestMetrics factory)Adds aRequestMetricswhose metrics will be recorded for request start and stop.InstrumenterBuilder<REQUEST,RESPONSE>addSpanLinksExtractor(SpanLinksExtractor<REQUEST> spanLinksExtractor)Adds aSpanLinksExtractorto extract span links from requests.Instrumenter<REQUEST,RESPONSE>newClientInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter)Returns a newInstrumenterwhich will create client spans and inject context into requests.Instrumenter<REQUEST,RESPONSE>newConsumerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter)Returns a newInstrumenterwhich will create consumer spans and extract context from requests.Instrumenter<REQUEST,RESPONSE>newInstrumenter()Returns a newInstrumenterwhich will create internal spans and do no context propagation.Instrumenter<REQUEST,RESPONSE>newInstrumenter(SpanKindExtractor<? super REQUEST> spanKindExtractor)Returns a newInstrumenterwhich will create spans with kind determined by the passedspanKindExtractorand do no context propagation.Instrumenter<REQUEST,RESPONSE>newProducerInstrumenter(io.opentelemetry.context.propagation.TextMapSetter<REQUEST> setter)Returns a newInstrumenterwhich will create producer spans and inject context into requests.Instrumenter<REQUEST,RESPONSE>newServerInstrumenter(io.opentelemetry.context.propagation.TextMapGetter<REQUEST> getter)Returns a newInstrumenterwhich will create server spans and extract context from requests.InstrumenterBuilder<REQUEST,RESPONSE>setDisabled(boolean disabled)InstrumenterBuilder<REQUEST,RESPONSE>setErrorCauseExtractor(ErrorCauseExtractor errorCauseExtractor)Sets theErrorCauseExtractorto extract the root cause from an exception handling the request.InstrumenterBuilder<REQUEST,RESPONSE>setSpanStatusExtractor(SpanStatusExtractor<? super REQUEST,? super RESPONSE> spanStatusExtractor)Sets theSpanStatusExtractorto use to determine theStatusCodefor a response.InstrumenterBuilder<REQUEST,RESPONSE>setTimeExtractor(TimeExtractor<REQUEST,RESPONSE> timeExtractor)Sets theTimeExtractorto extract the timestamp marking the start and end of processing.
-
-
-
Method Detail
-
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).
-
addRequestMetrics
@UnstableApi public InstrumenterBuilder<REQUEST,RESPONSE> addRequestMetrics(RequestMetrics factory)
Adds aRequestMetricswhose metrics will be recorded for request start and stop.
-
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).
-
setDisabled
public InstrumenterBuilder<REQUEST,RESPONSE> setDisabled(boolean disabled)
-
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
public Instrumenter<REQUEST,RESPONSE> 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.
-
-