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

Add ability to pass auxiliary attributes to set on GRPC trace #371

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tab1293
Copy link

@tab1293 tab1293 commented Oct 29, 2018

Overview

Support an optional aux_attributes parameter to OpenCensusClientInterceptor constructor in order to allow users to specify arbitrary tags on GRPC method trace spans.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@tab1293
Copy link
Author

tab1293 commented Oct 29, 2018

I have just signed the CLA

@googlebot
Copy link

CLAs look good, thanks!

@ocervell
Copy link
Contributor

ocervell commented Nov 1, 2018

+1 for this, I'd rename those to extra_attributes instead of aux_attributes.

Copy link
Member

@c24t c24t left a comment

Choose a reason for hiding this comment

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

A few comments, but it look good otherwise. What's the motivation for the change?

# Add user defined auxiliary attributes to span
if type(self.aux_attributes) is dict:
for attr_key, attr_value in self.aux_attributes.items():
if type(attr_key) is not str and type(attr_value) is not str:
Copy link
Member

Choose a reason for hiding this comment

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

Not or?

@@ -86,6 +87,16 @@ def _start_client_span(self, client_call_details):
attribute_key=attributes_helper.GRPC_ATTRIBUTES.get(GRPC_METHOD),
attribute_value=str(client_call_details.method))

# Add user defined auxiliary attributes to span
if type(self.aux_attributes) is dict:
Copy link
Member

Choose a reason for hiding this comment

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

Nit, but you might want isinstance(dict) here so e.g. defaultdicts work here too.

if type(self.aux_attributes) is dict:
for attr_key, attr_value in self.aux_attributes.items():
if type(attr_key) is not str and type(attr_value) is not str:
continue
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you're missing some coverage here: ...98% 94, 91->100, 93->94.

You can run coverage report -m -i $(git diff --name-only master) after running the tests with --cov=opencensus to check uncovered lines.

@tab1293 tab1293 requested review from aabmass, hectorhdzg, lzchen, songy23 and a team as code owners May 13, 2021 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants