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.
-
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.setSpanNameExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>, io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractorTransformer) Sets a transformer function that will modify theSpanNameExtractor.
-
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
-
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
InstrumenterCustomizer setSpanNameExtractor(Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>, io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<?>> spanNameExtractorTransformer) Sets a transformer function that will modify theSpanNameExtractor. This allows customizing how span names are generated for the instrumented operations.- Parameters:
spanNameExtractorTransformer- function that transforms the original span name extractor- Returns:
- this InstrumenterCustomizer for method chaining
-