-
Notifications
You must be signed in to change notification settings - Fork 176
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
WIP: Make Trace
compatible with OpenTelemetry
#180
Conversation
OpenTelemetry defines a bunch of [conventions for HTTP spans][conventions]. This makes adopting those conventions easy when using `Trace`: ```rust .layer(TraceLayer::new_for_http().opentelemetry_server()) ``` This changes the span for the request to: - Name: HTTP request - Fields: - `http.flavor`: "1.1" - `http.host`: "localhost:3000" - `http.method`: "GET" - `http.route`: "/users/123". Can be configured by user to instead be the path pattern for the route, ie `/users/:id` - `http.scheme`: "http". Must be set by user as middleware don't know this - `http.target`: "/users/123" - `http.user_agent`: "curl/7.64.1" - `http.client_ip`: Must be extracted by user in a "make service" - `http.status_code`: 200 - `request_id`: Requires #150. - `otel.kind`: "server" - `otel.status_code`: Unset or "ERROR" - `exception.message`: Set by user based on response classification. - `exception.details`: Set by user based on response classification. The fields are a bit different for HTTP clients hence the name `opentelemetry_server`. I don't think supporting clients initially is required. We can always add it later. TODO - [ ] Add `Trace::opentelemetry_server` method. Currently it only exists on the layer - [ ] Docs - [ ] Example using axum and `opentelemetry_jaeger` - [ ] Changelog [conventions]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md
When #181 is merged I'm gonna update it to use an opentelemetry config. |
I've removed this from the 0.2 milestone. Been thinking that it might be overly complicated and that a simpler solution should be possible. So think it needs more time to bake. Since its not a breaking change it doesn't have be included in 0.2 |
when this will ship, I'll definitely replace the use of warp's trace filter with tower + tower-http in my projects 🙏 the biggest fail for "warp's trace filter" when working with OpenTelemetry, is that it does not set |
@davidpdrsn It would be an amazing feature 😍 Could you give an example of usage you have in mind to go from Besides, I don't think having The OTEL doc says:
So it doesn't feel like a good default value to set the |
I don't think this will ship any time soon, definitely not in its current form. I think the implementation in this PR is too complicated. It shouldn't require implementing four traits... The I imagine that someday I (or someone else) will make a crate that contains an axum specific middleware. At Embark Studios we've been working on an implementation here but its not published to crates.io yet. Don't have a timeline on that I'm afraid. In fact I think I'll just close this PR. I don't like having stale PR lingering. |
OpenTelemetry defines a bunch of conventions for HTTP
spans. This makes adopting those conventions easy when
using
Trace
:This changes the span for the request to:
http.flavor
: "1.1"http.host
: "localhost:3000"http.method
: "GET"http.route
: "/users/123". Can be configured by user to instead bethe path pattern for the route, ie
/users/:id
http.scheme
: "http". Must be set by user as middleware don't knowthis
http.target
: "/users/123"http.user_agent
: "curl/7.64.1"http.client_ip
: Must be extracted by user in a "make service"http.status_code
: 200request_id
: Requires AddSetRequestId
andPropagateRequestId
middleware #150.otel.kind
: "server"otel.status_code
: Unset or "ERROR"exception.message
: Set by user based on response classification.exception.details
: Set by user based on response classification.The fields are a bit different for HTTP clients hence the name
opentelemetry_server
. I don't think supporting clients initially isrequired. We can always add it later.
TODO
Trace::opentelemetry_server
method. Currently it only existson the layer
opentelemetry_jaeger