Skip to content
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

Fix OpenTelemetry context propagation and duplication issues #25012

Merged
merged 6 commits into from
Oct 28, 2021

Conversation

lmolkova
Copy link
Member

@lmolkova lmolkova commented Oct 23, 2021

Fixes #24281, #22272

Before:

image

After:

Agent (1.6.2 or 1.7.0)
image

Application Insights (3.2.1) feels great too

image

@ghost ghost added the Azure.Core azure-core label Oct 23, 2021
@azure-sdk
Copy link
Collaborator

API changes have been detected in com.azure:azure-core. You can review API changes here

API changes

-         String PARENT_SPAN_KEY = "parent-span";
+         @Deprecated String PARENT_SPAN_KEY = "parent-span";
+         String TRACE_CONTEXT_KEY = "trace-context";

@azure-sdk
Copy link
Collaborator

API changes have been detected in com.azure:azure-core. You can review API changes here

API changes

-         String PARENT_SPAN_KEY = "parent-span";
+         @Deprecated String PARENT_SPAN_KEY = "parent-span";
+         String PARENT_TRACE_CONTEXT_KEY = "trace-context";

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to review the hard parts 😅

@lmolkova
Copy link
Member Author

I still need to review the hard parts 😅

thank you!

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got through the hard stuff 😅, thanks so much for getting this to work! I can't wait to auto-inject this new version from the agent 🎉

Comment on lines +31 to +35
Class<?> agentContextStorageClass = Class.forName("io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage");
Class<?> agentContextClass = Class.forName("io.opentelemetry.javaagent.shaded.io.opentelemetry.context.Context");
Class<?> spanKeyClass = Class.forName("io.opentelemetry.javaagent.shaded.instrumentation.api.instrumenter.SpanKey");
Class<?> bridgingClass = Class.forName("io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging");
Class<?> agentSpanClass = Class.forName("io.opentelemetry.javaagent.shaded.io.opentelemetry.api.trace.Span");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll add a test in the agent to make sure we don't accidentally break this from the agent side (the good news is that since we inject this from the agent we can coordinate)

@azure-sdk
Copy link
Collaborator

API changes have been detected in com.azure:azure-core. You can review API changes here

API changes

-         String PARENT_SPAN_KEY = "parent-span";
+         @Deprecated String PARENT_SPAN_KEY = "parent-span";
+         String PARENT_TRACE_CONTEXT_KEY = "trace-context";

.addData(spanImplContext, "<user-current-span-context>");
Context updatedProcessContext = tracer.start("azure.eventhubs.process", processContext,
Context updatedProcessContext = tracer.start("EventHubs.process", processContext,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this change be true for Http calls too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http spans still take parent context from the same context key. At the same time, they are always children of API-calls spans created by Tracer impl, so context passed by users is a grandparent for them and it never directly affects them.

@lmolkova lmolkova merged commit a3c84bb into Azure:main Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass the tracing context (instead of span) via the Azure Core Context
4 participants