OpenTelemetry span names for URLs are shortened
Integration
sentry-opentelemetry-agent
Java Version
any
Version
8
Steps to Reproduce
Have an endpoint like /person/extra/long/path and send a request in.
Expected Result
A meaningful transaction name.
Actual Result
The transaction name is shortened to GET /**.
We are using the http.route span attribute which contains above value.
When the URL has a corresponding route, then the http.route is populated with the correct value.
When there is no corresponding route/mapping for a specific URL, then http.route will contain GET /**.
In our SpanDescriptionExtractor we prioritize http.route.
Perhaps we could detect if http.route contains a * (or for stricter matching, if it matches exactly /**) and use url.path instead.
This is not perfect because the server might be mapped only to a specific path (not necessarily the apex) and with url.path we would report the whole path in the URL.
On a related note, this happens also in Servlet instrumentation, where http.route contains the path that the servlet is mapped to. See this recent issue about it https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/13802.
In my opinion, this behavior of setting http.route to e.g. GET /** for servlets is not conforming to the OTEL spec, because it says "MUST NOT be populated when this is not supported by the HTTP server framework".
If we consider the cardinality concern valid, then we should keep it as GET /**
If, instead, we think it's more valuable to have GET <full url> despite cardinality issues, then we could prioritize url.path when we detect that the url has been shortened.
Closing this issue as not planned because:
- we currently set the span name to
{method} {http.route}which is in accordance to the OTEL convention - the only usecase I can think of for having the full URL as the span name is to perform filtering/aggregation based on that value, in which case it's possible to filter/aggregate on the
url.pathattribute instead