-
Notifications
You must be signed in to change notification settings - Fork 271
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
Use correct semantic conventions for trace labels #3484
base: main
Are you sure you want to change the base?
Conversation
The OpenTelemetry spec defines the semantic conventions that HTTP services should use for the labels included in traces: https://opentelemetry.io/docs/specs/semconv/http/http-spans/ Previously, we were using an outdated version of this spec for the OpenCensus traces. This updates the labels to match the current spec. The notable changes updates to the path for HTTP method and status code, the fields that include the URL parts, and more rigorously following the standard for propagating the Host header. Signed-off-by: Scott Fleener <scott@buoyant.io>
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.
this looks good! i have two really minor nits to offer, but the change itself seems great 🙂
labels.insert("http.path", path); | ||
if let Some(authority) = req.uri().authority() { | ||
labels.insert("http.authority", authority.as_str().to_string()); | ||
let mut labels = HashMap::with_capacity(6); |
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.
nit: it looks like there are 7 entries:
url.scheme
, url.path
, url.query
, server.address
, server.port
, http.request.method
, and http.response.status_code
.
i'll call this a nit only because the capacity of 5
that was there before this PR has the same issue.
@@ -35,20 +36,35 @@ impl<K: Clone, S> TraceContext<K, S> { | |||
} | |||
|
|||
fn request_labels<B>(req: &http::Request<B>) -> HashMap<&'static str, String> { |
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.
fn request_labels<B>(req: &http::Request<B>) -> HashMap<&'static str, String> { | |
/// Returns labels for the provided request. | |
/// | |
/// The OpenTelemetry spec defines the semantic conventions that HTTP services should use for the labels included in traces: https://opentelemetry.io/docs/specs/semconv/http/http-spans/ | |
fn request_labels<B>(req: &http::Request<B>) -> HashMap<&'static str, String> { |
it might be nice to add a note documenting where the spec we are following lives.
nb: this suggestion will need to be formatted, sorry 🙈
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3484 +/- ##
==========================================
- Coverage 67.68% 66.76% -0.92%
==========================================
Files 332 388 +56
Lines 15158 18155 +2997
==========================================
+ Hits 10259 12122 +1863
- Misses 4899 6033 +1134
... and 174 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
The OpenTelemetry spec defines the semantic conventions that HTTP services should use for the labels included in traces: https://opentelemetry.io/docs/specs/semconv/http/http-spans/
Previously, we were using an outdated version of this spec for the OpenCensus traces. This updates the labels to match the current spec.
The notable changes updates to the path for HTTP method and status code, the fields that include the URL parts, and more rigorously following the standard for propagating the Host header.