-
Notifications
You must be signed in to change notification settings - Fork 780
opentelemetry: set span kind through otel.kind #890
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
Conversation
OpenTelemetry supports a span kind as special metadata to spans. The span kind defines relationships between spans (e.g. server vs client). Some distributed tracing providers use this information to enrich their UIs. This makes it possible to set the span kind by adding a special attribute called `otel.kind`, similar to the existing `otel.name`.
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.
Thanks @frigus02, this looks good to me. Could you also update the doc comments that currently reference span.kind
in https://github.com/tokio-rs/tracing/blob/master/tracing-opentelemetry/src/lib.rs#L26?
Change references of span.kind in the docs for the OpenTelemetry layer to otel.kind.
Oh yes, for sure. Good catch. I am wondering about the casing of the values. Should we use uppercase, lowercase or allow both? |
Case insensitive matching may make sense here? Could also wait for #811 but if a user currently does |
Yeah same thought, probably accepting both is the least confusing |
Agree, case insensitive matching sounds like the best option. I'm going to change that. Just need to look for the best way to do that 🙂 |
People may spell the span kind in different ways, e.g.: SERVER, server or Server. Using case insensitive matching is hopefully the least confusing.
Okay, here we go. I'm not sure if that's the best way, but it feels good enough. |
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.
Great thanks @frigus02, lgtm
Motivation
Some distributed tracing providers use information such as the span kind to enrich their UIs. The issue frigus02/opentelemetry-application-insights#5 shows an example with Azure Application Insights, which builds an application map based on client/server spans sent from multiple applications.
In order to make use of this with a combination of this
tracing
crate, together with OpenTelemetry exporters, we need a way of setting the span kind through the OpenTelemetry layer.Solution
This solves the issue by adding support for the special attribute
otel.kind
to the OpenTelemetry layer. If set toSERVER
,CLIENT
,PRODUCER
,CONSUMER
orINTERNAL
it sets the span kind of the internal OpenTelemetry span.This follows the convention introduced with the
otel.name
attribute, which sets the name of the internal OpenTelemetry span.