-
Notifications
You must be signed in to change notification settings - Fork 576
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
otelhttp should collect url information #3743
Comments
Could you provide a sample of the issue? As for I'll let @MrAlias chime in, but I think the intent was to remove it for metrics (where high cardinality is indeed an issue). So we could maybe add it only for traces? |
My mistake, yes, it does include method. What I'm really missing is the url path in the incoming request, but could also get that from http.url like it has on outgoing (client) requests. My current workaround is to add an additional filter in my request pipeline and add the attribute,
which just now looking at https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md I realize should be |
|
I ran into this, and came up with a workaround: I changed this: otelhttp.NewHandler(handler, serviceName, opts...) To this: wrappedHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Add the http.target attribute to the otelhttp span
if r.URL != nil {
oteltrace.SpanFromContext(r.Context()).SetAttributes(semconv.HTTPTarget(r.URL.RequestURI()))
}
handler.ServeHTTP(w, r)
})
otelhttp.NewHandler(wrappedHandler, serviceName, opts...) |
Looking at the latest specification, the HTTP Server Span should definitely provide |
We would love to use x-ray based sampling in respect of different routes on a reverse proxy (caddy). Sadly the missing propagation of Even the great workaround from @dashpole did not work here, as those context is added after the sampling decision. Does anybody have an idea how to add the targetUrl so the sampler will respect that? |
Migrating to the new semconv is tracked in https://github.com/orgs/open-telemetry/projects/87. We are required to implement the migration plan specified here: https://github.com/open-telemetry/semantic-conventions/tree/main/docs/http#semantic-conventions-for-http. |
Thanks for your quick reply. Sadly I have no access to the project (seems to be private). As we are not as experienced in OTEL / go instrumentation we found a hacky solution by providing a proxied TraceProvider which will read the That workaround should be sufficient to enable the request based sampling 😄 |
Ah, you can follow along here: #5331 |
Problem Statement
When I instrument my application using
otelhttp.NewHandler(...)
the spans it produces are missing method and path information which is important for understanding my system. The spans for requests it sends to other services (as a client) include this information, but the spans for requests it receives do not.Proposed Solution
Either by default, or by some
WithUrlAttributes
option, it spans for incoming http requests should include Url information and set the standard http.url attributes.The text was updated successfully, but these errors were encountered: