This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Update gRPC client interceptor to use tracer from execution context#157
Merged
liyanhui1228 merged 2 commits intocensus-instrumentation:masterfrom Apr 19, 2018
Merged
Conversation
| grpc.StreamUnaryClientInterceptor, | ||
| grpc.StreamStreamClientInterceptor): | ||
|
|
||
| def __init__(self, tracer=None, host_port=None): |
Contributor
Contributor
Author
There was a problem hiding this comment.
Will do!
Would the current integration in google_cloud_clientlibs be facing this same issue if it is passing in the tracer at initialization time? For instance, if a Flask endpoint calls a gcloud service, would the gcloud span be nested under the flask one?
Contributor
There was a problem hiding this comment.
Thanks for the fix! Yes I have opened a new issue #161, I'll look into and work on it later this week.
| tracer.add_attribute_to_current_span( | ||
| attribute_key=attributes_helper.GRPC_ATTRIBUTES.get(GRPC_METHOD), | ||
| attribute_value=str(client_call_details.method)) | ||
|
|
Contributor
There was a problem hiding this comment.
Probably add code below to here to update the tracer in execution context:
execution_context.set_opencensus_tracer(self._tracer)
execution_context.set_current_span(span)
liyanhui1228
approved these changes
Apr 19, 2018
sonmezonur
pushed a commit
to sonmezonur/opencensus-python
that referenced
this pull request
Apr 22, 2018
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Ran into this when calling a gRPC client from within a flask endpoint handler. The tracer was set once when the interceptor was created and never updated afterwards.