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 Type
    Method
    Description
    addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?,?> extractor)
    Adds a single AttributesExtractor to the instrumenter.
    addAttributesExtractors(Iterable<? extends io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<?,?>> extractors)
    Adds multiple AttributesExtractors to the instrumenter.
    addContextCustomizer(io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<?> customizer)
    Adds a ContextCustomizer that will customize the context during Instrumenter.start(Context, Object).
    addOperationMetrics(io.opentelemetry.instrumentation.api.instrumenter.OperationMetrics operationMetrics)
    Adds an OperationMetrics implementation 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 the SpanNameExtractor.
  • 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 single AttributesExtractor to 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 multiple AttributesExtractors 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 an OperationMetrics implementation 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 a ContextCustomizer that will customize the context during Instrumenter.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 the SpanNameExtractor. 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