-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move opentelemetry-api-1.0 instrumentation under v1_0 subpackage #18886
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 8 commits into
open-telemetry:main
from
trask:package-name-cleanup-opentelemetry-api
Jun 8, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7d902f5
Move opentelemetry-api-1.0 instrumentation under v1_0 subpackage
trask a756ca5
Fix azure-core instrumentation, including indy
trask 1a589a3
Potential fix for pull request finding
trask e4719a8
Merge remote-tracking branch 'upstream/main' into package-name-cleanu…
trask 8a7e37b
spotless
trask 8ffdaed
Address review comment from Copilot: use Azure parent context key
trask 886f6a6
Backport Azure explicit parent context bridge to 1.36
trask 199fb7d
Address review comment from Copilot: document Azure parent context key
trask 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
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
51 changes: 51 additions & 0 deletions
51
.../opentelemetry/javaagent/instrumentation/azurecore/v1_36/AzureContextInstrumentation.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,51 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.azurecore.v1_36; | ||
|
|
||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||
|
|
||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import java.util.Optional; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.asm.Advice.AssignReturned; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| /** | ||
| * Bridges an explicitly supplied parent context for {@code azure-core-tracing-opentelemetry}. | ||
| * | ||
| * <p>When a user passes a parent context to an Azure SDK call, the value is stored on the {@link | ||
| * com.azure.core.util.Context} under {@link | ||
| * com.azure.core.util.tracing.Tracer#PARENT_TRACE_CONTEXT_KEY} as the application's (unshaded) | ||
| * {@code io.opentelemetry.context.Context}. The bundled {@code OpenTelemetryTracer} reads that | ||
| * value back and expects it to be the agent's (shaded) context. Convert it here so the tracer does | ||
| * not need to reach into agent internals reflectively. | ||
| */ | ||
| class AzureContextInstrumentation implements TypeInstrumentation { | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("com.azure.core.util.Context"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| named("getData").and(takesArguments(1)), getClass().getName() + "$GetDataAdvice"); | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class GetDataAdvice { | ||
| @AssignReturned.ToReturned | ||
| @Advice.OnMethodExit(suppress = Throwable.class, inline = false) | ||
| public static Optional<Object> onExit( | ||
| @Advice.Argument(0) Object key, @Advice.Return Optional<Object> data) { | ||
| return AzureExplicitParentContextHelper.bridgeApplicationContext(key, data); | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
...telemetry/javaagent/instrumentation/azurecore/v1_36/AzureExplicitParentContextHelper.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,42 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.azurecore.v1_36; | ||
|
|
||
| import static com.azure.core.util.tracing.Tracer.PARENT_TRACE_CONTEXT_KEY; | ||
|
|
||
| import io.opentelemetry.context.Context; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Converts an explicitly supplied application parent context into the agent context. | ||
| * | ||
| * <p>In the agent the application's {@code io.opentelemetry.context.Context} (referenced here as | ||
| * {@code application.io.opentelemetry.context.Context}) is bridged to the agent context by the | ||
| * opentelemetry-api instrumentation. Making the application context current and reading back the | ||
| * agent context performs that conversion using only public API, so this works in both inline and | ||
| * indy mode without reaching into agent-internal helper classes. | ||
| */ | ||
| public final class AzureExplicitParentContextHelper { | ||
|
|
||
| public static Optional<Object> bridgeApplicationContext(Object key, Optional<Object> data) { | ||
| if (!PARENT_TRACE_CONTEXT_KEY.equals(key) || data == null || !data.isPresent()) { | ||
| return data; | ||
| } | ||
| Object value = data.get(); | ||
| if (!(value instanceof application.io.opentelemetry.context.Context)) { | ||
| return data; | ||
| } | ||
| application.io.opentelemetry.context.Context applicationContext = | ||
| (application.io.opentelemetry.context.Context) value; | ||
| Context agentContext; | ||
| try (application.io.opentelemetry.context.Scope ignored = applicationContext.makeCurrent()) { | ||
| agentContext = Context.current(); | ||
| } | ||
| return Optional.of(agentContext); | ||
| } | ||
|
|
||
| private AzureExplicitParentContextHelper() {} | ||
| } |
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
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
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
51 changes: 51 additions & 0 deletions
51
.../opentelemetry/javaagent/instrumentation/azurecore/v1_53/AzureContextInstrumentation.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,51 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.azurecore.v1_53; | ||
|
|
||
| import static net.bytebuddy.matcher.ElementMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.takesArguments; | ||
|
|
||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
| import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
| import java.util.Optional; | ||
| import net.bytebuddy.asm.Advice; | ||
| import net.bytebuddy.asm.Advice.AssignReturned; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| /** | ||
| * Bridges an explicitly supplied parent context for {@code azure-core-tracing-opentelemetry}. | ||
| * | ||
| * <p>When a user passes a parent context to an Azure SDK call, the value is stored on the {@link | ||
| * com.azure.core.util.Context} under {@link | ||
| * com.azure.core.util.tracing.Tracer#PARENT_TRACE_CONTEXT_KEY} as the application's (unshaded) | ||
| * {@code io.opentelemetry.context.Context}. The bundled {@code OpenTelemetryTracer} reads that | ||
| * value back and expects it to be the agent's (shaded) context. Convert it here so the tracer does | ||
| * not need to reach into agent internals reflectively. | ||
| */ | ||
| class AzureContextInstrumentation implements TypeInstrumentation { | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> typeMatcher() { | ||
| return named("com.azure.core.util.Context"); | ||
| } | ||
|
|
||
| @Override | ||
| public void transform(TypeTransformer transformer) { | ||
| transformer.applyAdviceToMethod( | ||
| named("getData").and(takesArguments(1)), getClass().getName() + "$GetDataAdvice"); | ||
| } | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public static class GetDataAdvice { | ||
| @AssignReturned.ToReturned | ||
| @Advice.OnMethodExit(suppress = Throwable.class, inline = false) | ||
| public static Optional<Object> onExit( | ||
| @Advice.Argument(0) Object key, @Advice.Return Optional<Object> data) { | ||
| return AzureExplicitParentContextHelper.bridgeApplicationContext(key, data); | ||
| } | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
...telemetry/javaagent/instrumentation/azurecore/v1_53/AzureExplicitParentContextHelper.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,42 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.javaagent.instrumentation.azurecore.v1_53; | ||
|
|
||
| import static com.azure.core.util.tracing.Tracer.PARENT_TRACE_CONTEXT_KEY; | ||
|
|
||
| import io.opentelemetry.context.Context; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Converts an explicitly supplied application parent context into the agent context. | ||
| * | ||
| * <p>In the agent the application's {@code io.opentelemetry.context.Context} (referenced here as | ||
| * {@code application.io.opentelemetry.context.Context}) is bridged to the agent context by the | ||
| * opentelemetry-api instrumentation. Making the application context current and reading back the | ||
| * agent context performs that conversion using only public API, so this works in both inline and | ||
| * indy mode without reaching into agent-internal helper classes. | ||
| */ | ||
| public final class AzureExplicitParentContextHelper { | ||
|
|
||
| public static Optional<Object> bridgeApplicationContext(Object key, Optional<Object> data) { | ||
| if (!PARENT_TRACE_CONTEXT_KEY.equals(key) || data == null || !data.isPresent()) { | ||
| return data; | ||
| } | ||
| Object value = data.get(); | ||
| if (!(value instanceof application.io.opentelemetry.context.Context)) { | ||
| return data; | ||
| } | ||
| application.io.opentelemetry.context.Context applicationContext = | ||
| (application.io.opentelemetry.context.Context) value; | ||
| Context agentContext; | ||
| try (application.io.opentelemetry.context.Scope ignored = applicationContext.makeCurrent()) { | ||
| agentContext = Context.current(); | ||
| } | ||
| return Optional.of(agentContext); | ||
| } | ||
|
|
||
| private AzureExplicitParentContextHelper() {} | ||
| } |
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
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
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
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
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
Oops, something went wrong.
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.