-
Notifications
You must be signed in to change notification settings - Fork 1k
Support extensions for attributesExtractors, contextCustomizers, operationListeners and spanNameExtractor #13917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
trask
merged 23 commits into
open-telemetry:main
from
steverao:support-custom-extention
Aug 14, 2025
Merged
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7b4c56d
Support extensions for attributesExtractors, contextCustomizers and o…
steverao 8ba2bf0
Fix failing test
steverao 84b1c70
Merge branch 'main' into support-custom-extention
steverao 5531d16
Fix failing CI
steverao 35da705
Add necessary description of classes
steverao 30182a3
Address review comments
steverao 6972f96
Address review comments
steverao 59662da
Moved API to internal directory
steverao 798ba56
Moved API to internal directory
steverao 611aa90
Moved API to internal directory
steverao 891822a
Fix CI failing
steverao 7ed6e43
Add support for spanNameExtractor
steverao da46f57
Support extensions for spanNameExtractor
steverao 7109962
Optimize codes
steverao 159e53d
Refactor extension to be consistent with existence.
steverao e7d8de3
Move customizer api to incubator module (#9)
laurit fb9d6c6
Optimize codes
steverao 5c0489c
Add example
steverao f11181d
Removed unexpected part in example
steverao 47bf9da
Fix formatting in DemoInstrumenterCustomizerProvider
steverao 49a2e90
Address review comments
steverao 26e1675
Add missing imports in InstrumenterCustomizer
steverao 5ca4e61
Update README to clarify customization conditions based on instrument…
steverao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 17 additions & 1 deletion
18
docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,18 @@ | ||
| Comparing source compatibility of opentelemetry-instrumentation-api-2.17.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.16.0.jar | ||
| No changes. | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractorCustomizer (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE> get() | ||
| GENERIC TEMPLATES: +++ REQUEST:java.lang.Object, +++ RESPONSE:java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.List<java.lang.String> instrumentationNames() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizerCustomizer (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.ContextCustomizer<REQUEST> get() | ||
| GENERIC TEMPLATES: +++ REQUEST:java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.List<java.lang.String> instrumentationNames() | ||
| +++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.OperationMetricsCustomizer (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.instrumenter.OperationMetrics get() | ||
| +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.util.List<java.lang.String> instrumentationNames() |
38 changes: 38 additions & 0 deletions
38
...java/io/opentelemetry/instrumentation/api/instrumenter/AttributesExtractorCustomizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A service provider interface (SPI) for providing {@link AttributesExtractorCustomizer} instances | ||
| * that are conditionally applied based on the instrumentation name. | ||
| * | ||
| * <p>This allows external modules or plugins to contribute custom attribute extraction logic for | ||
| * specific instrumented libraries, without modifying core instrumentation code. | ||
| */ | ||
| public interface AttributesExtractorCustomizer { | ||
| /** | ||
| * Returns a list of instrumentation names that this customizer supports. | ||
| * | ||
| * <p>The customizer will only be applied if the current instrumentation matches one of the | ||
| * returned names. For example: ["io.opentelemetry.netty-3.8", | ||
| * "io.opentelemetry.apache-httpclient-4.3"]. | ||
| * | ||
| * @return a list of supported instrumentation names | ||
| */ | ||
| List<String> instrumentationNames(); | ||
|
|
||
| /** | ||
| * Returns a new instance of an {@link AttributesExtractor} that will extract attributes from | ||
| * requests and responses during the instrumentation process. | ||
| * | ||
| * @param <REQUEST> the type of request object used by the instrumented library | ||
| * @param <RESPONSE> the type of response object used by the instrumented library | ||
| * @return an attributes extractor instance | ||
| */ | ||
| <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> get(); | ||
| } | ||
38 changes: 38 additions & 0 deletions
38
...n/java/io/opentelemetry/instrumentation/api/instrumenter/ContextCustomizerCustomizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A service provider interface (SPI) for providing custom {@link ContextCustomizer} implementations | ||
| * that are conditionally applied based on the instrumentation name. | ||
| * | ||
| * <p>This allows external modules or plugins to customize context propagation and initialization | ||
| * logic for specific instrumented libraries, without modifying core instrumentation code. | ||
| */ | ||
| public interface ContextCustomizerCustomizer { | ||
steverao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Returns a list of instrumentation names that this customizer supports. | ||
| * | ||
| * <p>The customizer will only be applied if the current instrumentation matches one of the | ||
| * returned names. For example: ["io.opentelemetry.netty-3.8", | ||
| * "io.opentelemetry.apache-httpclient-4.3"]. | ||
| * | ||
| * @return a list of supported instrumentation names | ||
| */ | ||
| List<String> instrumentationNames(); | ||
steverao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Returns a new instance of a {@link ContextCustomizer} that will customize the tracing context | ||
| * during request processing. | ||
| * | ||
| * @param <REQUEST> the type of request object used by the instrumented library | ||
| * @return a context customizer instance | ||
| */ | ||
| <REQUEST> ContextCustomizer<REQUEST> get(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...in/java/io/opentelemetry/instrumentation/api/instrumenter/OperationMetricsCustomizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * A service provider interface (SPI) for providing custom {@link OperationMetrics} instances that | ||
| * are conditionally applied based on the instrumentation name. | ||
| * | ||
| * <p>This allows external modules or plugins to contribute custom metrics collection logic for | ||
| * specific instrumented operations, without modifying core instrumentation code. | ||
| */ | ||
| public interface OperationMetricsCustomizer { | ||
|
|
||
| /** | ||
| * Returns a list of instrumentation names that this metrics customizer supports. | ||
| * | ||
| * <p>The customizer will only be applied if the current instrumentation matches one of the | ||
| * returned names. For example: ["io.opentelemetry.spring-webmvc-5.0", | ||
| * "io.opentelemetry.netty-3.8"]. | ||
| * | ||
| * @return a list of supported instrumentation names | ||
| */ | ||
| List<String> instrumentationNames(); | ||
|
|
||
| /** | ||
| * Returns a new instance of an {@link OperationMetrics} that will record metrics for the | ||
| * instrumented operation. | ||
| * | ||
| * @return an operation metrics instance | ||
| */ | ||
| OperationMetrics get(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.