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

Support OTEL_RESOURCE_ATTRIBUTES environmental variable #146

Closed
dhpollack opened this issue May 19, 2021 · 5 comments
Closed

Support OTEL_RESOURCE_ATTRIBUTES environmental variable #146

dhpollack opened this issue May 19, 2021 · 5 comments
Labels
enhancement New feature or request trace

Comments

@dhpollack
Copy link
Contributor

I created a PR (#145) to support this environmental variable which is part of the OTEL specification. I want to be able to add custom attributes to all spans of a specific service and this is the easiest way to do it. The current resource attribute getter ignores these attributes and only gets gcp specific ones.

@aabmass
Copy link
Collaborator

aabmass commented May 21, 2021

Thanks for the PR! The OTEL_RESOURCE_ATTRIBUTES environment variable is already implemented in OpenTelemetry Python (see these docs), so your PR doesn't need to implement that.

I want to be able to add custom attributes to all spans of a specific service and this is the easiest way to do it.

I'm curious what kind of attributes you want to add, do they actually fit the model of a "resource"?

The current resource attribute getter ignores these attributes and only gets gcp specific ones.

This is true, we should probably pass the rest on as span attributes since Cloud Trace doesn't have a first-class resource concept right now. Just be aware that it will be a lot of repetitive information in your spans!

@dhpollack
Copy link
Contributor Author

I wanted to initially add the name of the app via "service.name". We do something more manually with open census and middleware but this seems to make more sense because the information is already in the span, just not exported to gcp. In the future I was thinking of using it to tag spans globally and do some A/B testing.

@aabmass
Copy link
Collaborator

aabmass commented May 21, 2021

Gotcha, service name definitely belongs in resource. What kind of GCP compute are you running this on btw? I think we should add this feature but probably it should be off by default and have an option in the exporter's constructor to enable it.

In the future I was thinking of using it to tag spans globally and do some A/B testing.

This sounds more like baggage is what you want here, to propagate extra key values between services. It's still not 100% clear how baggage makes it way into a span open-telemetry/opentelemetry-specification#867, but you could write a span processor to modify the span based on the parent context.

@dhpollack
Copy link
Contributor Author

I think it's more that if I add a resource with the otel environmental variable, I expect to see it. I agree what I'm doing with this feature could be misguided but I need to figure that out on my own. :-)

I ended up spending hours with this until I used the console exporter and realized the data was added to the span but not to the data uploaded to Google.

@jsuereth jsuereth added enhancement New feature or request monitoring and removed monitoring labels May 24, 2021
@aabmass aabmass added the trace label May 24, 2021
@aabmass
Copy link
Collaborator

aabmass commented May 24, 2021

@dhpollack let do this:

I think we should add this feature but probably it should be off by default and have an option in the exporter's constructor to enable it.

I'll comment on your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request trace
Projects
None yet
Development

No branches or pull requests

3 participants