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

Implement ContextStorageOverride for opentelemetry context bridge #11523

Merged
merged 2 commits into from
Sep 19, 2024

Conversation

YifeiZhuang
Copy link
Contributor

@YifeiZhuang YifeiZhuang commented Sep 13, 2024

b/357892637
follow up with #11500

opencensus shim will find opentelmetry context when using opencensus {@link io.opencensus.trace.unsafe.ContextManagerImpl}, but does not solve the problem of bridging io.grpc.context and io.opentelemetry.context

otel implementation does not have otel over grpc contxt:
https://github.com/open-telemetry/opentelemetry-java/blob/18d192d1fadc6f6dd4dfbff01c0c139eaf93c604/context/src/grpcInOtelTest/java/io/grpc/override/ContextStorageOverride.java

other implementation:
https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/instrumentation/grpc-1.6/library#library-instrumentation-for-grpc-160

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Only concern is the name.

public Context current() {
io.opentelemetry.context.Context otelCurrent = io.opentelemetry.context.Context.current();
io.grpc.Context grpcCurrent = otelCurrent.get(GRPC_CONTEXT_OVER_OTEL);
if (grpcCurrent == null) {
Copy link
Member

Choose a reason for hiding this comment

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

FYI: you could use Context.keyWithDefault("blah", Context.Root) to let the API handle this for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, this only works for io.opentelemetry.context.keyWithDefault but they don't have this convenient API.

settings.gradle Outdated
@@ -76,6 +76,7 @@ include ":grpc-istio-interop-testing"
include ":grpc-inprocess"
include ":grpc-util"
include ":grpc-opentelemetry"
include ":grpc-context-storage-override"
Copy link
Member

Choose a reason for hiding this comment

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

The name of the package is clearly io.grpc.context-related. However, nothing speaks to "otel" in the name. context-opentelementry-storage (+override?) as the name? (context-storage-override-opentelemetry?)

contextstorage/build.gradle Outdated Show resolved Hide resolved
@YifeiZhuang YifeiZhuang merged commit 782a44a into grpc:master Sep 19, 2024
15 checks passed
@YifeiZhuang YifeiZhuang deleted the otel-context branch September 19, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants