Interface InstrumenterCustomizer
- All Known Implementing Classes:
InstrumenterCustomizerImpl
public interface InstrumenterCustomizer
Provides customizations for instrumentation, including operation metrics, attributes extraction,
and context customization.
This class is passed to InstrumenterCustomizerProvider.customize(InstrumenterCustomizer) to allow external modules or
plugins to contribute custom logic for specific instrumented libraries, without modifying core
instrumentation code. This class is internal and is hence not for public use. Its APIs are
unstable and can change at any time.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumTypes of instrumentation. -
Method Summary
Modifier and TypeMethodDescriptionaddAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?, ?> extractor) Adds a singleAttributesExtractorto the instrumenter.addAttributesExtractors(Iterable<? extends io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?, ?>> extractors) Adds multipleAttributesExtractors to the instrumenter.addContextCustomizer(io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<?> customizer) Adds aContextCustomizerthat will customize the context duringInstrumenter.start(Context, Object).addOperationMetrics(io.opentelemetry.instrumentation.api.instrumenter.OperationMetrics operationMetrics) Adds anOperationMetricsimplementation to the instrumenter.Returns the name of the instrumentation that this customizer applies to.booleanTests whether given instrumenter produces telemetry of specified type.default InstrumenterCustomizersetSpanNameExtractor(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractor) Deprecated.setSpanNameExtractorCustomizer(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractorCustomizer) Sets a transformer function that will modify theSpanNameExtractor.default InstrumenterCustomizersetSpanStatusExtractor(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<?, ?>> spanStatusExtractor) Deprecated.UsesetSpanStatusExtractorCustomizer(UnaryOperator)instead.setSpanStatusExtractorCustomizer(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<?, ?>> spanStatusExtractorCustomizer) Sets a transformer function that will modify theSpanStatusExtractor.
-
Method Details
-
getInstrumentationName
String getInstrumentationName()Returns the name of the instrumentation that this customizer applies to.- Returns:
- the name of the instrumentation this customizer targets
-
hasType
Tests whether given instrumenter produces telemetry of specified type. Instrumentation type is detected based on the standardAttributesExtractorimplementations used by this instrumenter e.g. instrumenters that useHttpClientAttributesExtractorhaveInstrumenterCustomizer.InstrumentationType.HTTP_CLIENTtype.- Returns:
- the name of the instrumentation this customizer targets
-
addAttributesExtractor
InstrumenterCustomizer addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?, ?> extractor) Adds a singleAttributesExtractorto the instrumenter. This extractor will be used to extract attributes from requests and responses during the request lifecycle.- Parameters:
extractor- the attributes extractor to add- Returns:
- this InstrumenterCustomizer for method chaining
-
addAttributesExtractors
InstrumenterCustomizer addAttributesExtractors(Iterable<? extends io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?, ?>> extractors) Adds multipleAttributesExtractors to the instrumenter. These extractors will be used to extract attributes from requests and responses during the request lifecycle.- Parameters:
extractors- the collection of attributes extractors to add- Returns:
- this InstrumenterCustomizer for method chaining
-
addOperationMetrics
InstrumenterCustomizer addOperationMetrics(io.opentelemetry.instrumentation.api.instrumenter.OperationMetrics operationMetrics) Adds anOperationMetricsimplementation to the instrumenter. This will be used to create metrics for the instrumented operations.- Parameters:
operationMetrics- the metrics factory to add- Returns:
- this InstrumenterCustomizer for method chaining
-
addContextCustomizer
InstrumenterCustomizer addContextCustomizer(io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<?> customizer) Adds aContextCustomizerthat will customize the context duringInstrumenter.start(Context, Object).- Parameters:
customizer- the context customizer to add- Returns:
- this InstrumenterCustomizer for method chaining
-
setSpanNameExtractor
@Deprecated default InstrumenterCustomizer setSpanNameExtractor(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractor) Deprecated.UsesetSpanNameExtractorCustomizer(UnaryOperator)instead.Sets a transformer function that will modify theSpanNameExtractor. This allows customizing how span names are generated for the instrumented operations.- Parameters:
spanNameExtractor- function that transforms the original span name extractor- Returns:
- this InstrumenterCustomizer for method chaining
-
setSpanNameExtractorCustomizer
InstrumenterCustomizer setSpanNameExtractorCustomizer(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractorCustomizer) Sets a transformer function that will modify theSpanNameExtractor. This allows customizing how span names are generated for the instrumented operations.- Parameters:
spanNameExtractorCustomizer- function that transforms the original span name extractor- Returns:
- this InstrumenterCustomizer for method chaining
-
setSpanStatusExtractor
@Deprecated default InstrumenterCustomizer setSpanStatusExtractor(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<?, ?>> spanStatusExtractor) Deprecated.UsesetSpanStatusExtractorCustomizer(UnaryOperator)instead.Sets a transformer function that will modify theSpanStatusExtractor. This allows customizing how span statuses are generated for the instrumented operations.- Parameters:
spanStatusExtractor- function that transforms the original span status extractor- Returns:
- this InstrumenterCustomizer for method chaining
-
setSpanStatusExtractorCustomizer
InstrumenterCustomizer setSpanStatusExtractorCustomizer(UnaryOperator<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<?, ?>> spanStatusExtractorCustomizer) Sets a transformer function that will modify theSpanStatusExtractor. This allows customizing how span statuses are generated for the instrumented operations.- Parameters:
spanStatusExtractorCustomizer- function that transforms the original span status extractor- Returns:
- this InstrumenterCustomizer for method chaining
-
setSpanNameExtractorCustomizer(UnaryOperator)instead.