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
Method to add service_name to all spans #34
Conversation
It's useful to have a way to set the service name for all spans at once, rather than having to set it every time. This commit adds a with_service_name method to PipelineBuilder and Exporter to allow users to set the service name in one place, following the behaviour of the official DataDog and Zipkin exporters. It also sets a default service_name if the user does not configure one.
Thanks a lot. I think this makes sense to me. I want to have another look at the spec to remind myself how service.name is supposed to work. Will try to do this tomorrow. |
I looked a bit closer now. My thoughts are:
For Application Insights we use the service.name to set the Cloud role context tag. As far as I know this tag is optional. But I don't know if there is a best practice around setting this to some default value. If there is, it definitely makes sense to add that here. Based on this my feeling is that:
I'm happy to help with any of those. What do you think? |
Thank you for your detailed reply, and apologies for not replying sooner!
I've talked through this with my coworker who knows more Rust than I do (I'm afraid I'm quite new at it), and he and I can work on rewriting the convenience function for the pipeline builder so that it adds Based on the specification for resources, it looks like the correct behaviour if someone sets The other two changes (adding the correct behaviour to opentelemetry-rust, and fixing the Zipkin and Jaeger exporters) both sound good, but I'm not sure I have the bandwidth or the knowledge of Rust to help with them. Would it be okay to implement the spec-compliant default in opentelemetry-application-insights for now, and then move it over to opentelemetry-rust later? I can include that as part of this PR as well. |
Rather than relying on a property on PipelineBuilder, instead set the service.name in the sdk::Config by merging sdk::Resouce properties. This is also a change to the behavior of with_config.
Co-authored-by: isobelhooper <isobel.hooper@cambridgequantum.com>
Set service.name through sdk::Resource
Hi @isobelhooper, sorry for the delayed response. This looks great, thank you. I'm going to create a new release with this soon. Regarding the Zipkin/Jaeger changes: don't worry about it. It's cool if you happen to find the time. I'm sure otherwise someone else is going to do it eventually 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just found 2 minor things that we could write differently. I might change that later. But it doesn't block this.
I just pushed version 0.14.0. Thanks for working on this! 🙂 |
/// Assign the service name under which to group traces by adding a service.name | ||
/// `sdk::Resource` or overriding a previous setting of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that "overriding a previous setting" is not true with the current version 0.13.0 of opentelemetry
. We just updated the sdk::Resource::merge
logic to reflect the latest spec in open-telemetry/opentelemetry-rust#537. This will be included in the next release, though.
This commit adds a
with_service_name
method to PipelineBuilder and Exporter to allow users to set the service name in one place, following the behaviour of the Datadog and Zipkin exporters.It also sets a default
service.name
value if the user does not configure one.I noticed that the doc test for
with_trace_config
already handles this particular case, but having a method specifically for it would match other exporters, and would also make it possible to supply a default value.