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

gRPC: provide the ability to set additional attributes for the generated spans #838

Closed
vadimberezniker opened this issue Jun 29, 2021 · 2 comments

Comments

@vadimberezniker
Copy link
Contributor

Our use case is as follows.
We implement a third-party API (Bazel Remote Execution) and most of the requests have a well known identifier called the invocation ID. I would like to add the invocation ID to the generated spans so that it's easy to find traces by invocation ID.

I patched our version of opentelemetry-go-contrib:
https://github.com/open-telemetry/opentelemetry-go-contrib/compare/main...vadimberezniker:context_hook?expand=1

My questions are:
(1) Is it already somehow possible to accomplish this without modifying the instrumentation code?
(2) Are you interested in this patch?

@vadimberezniker
Copy link
Contributor Author

vadimberezniker commented Jul 1, 2021

Figured out how to do it without modifying the instrumentation code and it's apparently super simple.
Add another interceptor that retrieves the current span and adds an attribute.

span := trace.SpanFromContext(ctx)
span.SetAttributes(...)

@Aneurysm9
Copy link
Member

Figured out how to do it without modifying the instrumentation code and it's super simple.
Add another interceptor that retrieves the current Spans and adds an attribute.

span := trace.SpanFromContext(ctx)
span.SetAttributes(...)

Heh, I was going to suggest this but I assumed you were looking for a more generic approach. I don't do much (read anything) with gRPC so I assumed there was a complication I was missing. Glad you've come to a working solution!

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

No branches or pull requests

2 participants