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

Use correct semantic conventions for trace labels #3484

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sfleen
Copy link
Collaborator

@sfleen sfleen commented Dec 20, 2024

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.

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>
@sfleen sfleen requested a review from a team as a code owner December 20, 2024 16:47
Copy link
Collaborator

@cratelyn cratelyn left a 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);
Copy link
Collaborator

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> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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 🙈

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 66.76%. Comparing base (96124bc) to head (005dd47).
Report is 680 commits behind head on main.

Files with missing lines Patch % Lines
linkerd/trace-context/src/service.rs 0.00% 19 Missing ⚠️
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     
Files with missing lines Coverage Δ
linkerd/trace-context/src/service.rs 16.66% <0.00%> (-3.34%) ⬇️

... and 174 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1a5713...005dd47. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants