-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[confighttp] otelhttp-generated span names may have high cardinality #12468
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
Comments
If the handler supplied to ToServer is an *http.ServeMux, use its Handler method to determine the matching pattern and use that to name the span as described at https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name If there is no matching pattern, fall back to "unknown route". Fixes open-telemetry#12468
If the handler supplied to ToServer is an *http.ServeMux, use its Handler method to determine the matching pattern and use that to name the span as described at https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name If there is no matching pattern, fall back to "unknown route". Fixes open-telemetry#12468
If the handler supplied to ToServer is an *http.ServeMux, use its Handler method to determine the matching pattern and use that to name the span as described at https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name If there is no matching pattern, fall back to "unknown route". Fixes open-telemetry#12468
If the handler supplied to ToServer is an *http.ServeMux, use its Handler method to determine the matching pattern and use that to name the span as described at https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name If there is no matching pattern, fall back to "unknown route". Fixes open-telemetry#12468
I have a possible solution at #12593. There's an alternative described in the PR description. |
If the handler supplied to ToServer is an *http.ServeMux, use its Handler method to determine the matching pattern and use that to name the span as described at https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name If there is no matching pattern, fall back to "unknown route". Fixes open-telemetry#12468
@axw I think the path should be okay here for the span name because it will be low cardinality unless your Collector is under some sort of 404 spam attack. In this case, maybe we could have a middleware running at the end of the request lifecycle, when there might already be a 404 status code sent and rename the span at this moment? |
@douglascamata agreed, this is only likely to be a problem if a security scanner or some malicious client is sending spurious requests to your collector. That's not uncommon.
How would you know that the 404 is due to there being no missing route vs. a matching route whose handler returns 404? Probably not likely, but also not impossible. Another option, that we have implemented, is to put an ingress in front that allows only a strictly controlled set of paths through to the collector - so anything that's not a registered route will be filtered out before it hits the collector. So it's not terrible as it is, but seems like we could improve things and follow the instrumentation recommendations. |
True, that would be a downside of my idea. I don't think though it would affect the Collector (please correct me if I'm wrong), because it's not using 404 as widely as a an API that follows the REST patterns very strictly.
100% agreed. The Collector already partially follows some of the recommendation, i.e. it does not include the query parameters in the span name. Personally I don't recall seeing a lot of tracing code out there that defends itself well against 404 attacks. It's good to think about it though and maybe create a good solution for this that could help many out there. |
Component(s)
No response
What happened?
Describe the bug
The
otelhttp
instrumentation inconfighttp
uses the URL path for span names:opentelemetry-collector/config/confighttp/confighttp.go
Lines 468 to 470 in 2b5fa0e
According to https://opentelemetry.io/docs/specs/semconv/http/http-spans/#name:
I realise it's a SHOULD and not a MUST, but I would expect OpenTelemetry Collector to be setting an example and following documented recommendations. Producing high cardinality span names can be problematic for certain pipelines, e.g. when aggregating spans by name.
Steps to reproduce
examples/local/otel-config.yaml
:make run
curl http://localhost:4318/foo/bar
What did you expect to see?
I would expect to see a span logged with the name
GET
, or something low-cardinality but more descriptive likeGET unknown route
.What did you see instead?
A span is logged with the name
/foo/bar
:Collector version
2b5fa0e
Environment information
Environment
OS: Ubuntu 24.04
Compiler: go 1.24.0
OpenTelemetry Collector configuration
Log output
Additional context
No response
The text was updated successfully, but these errors were encountered: