opentelemetry-java-instrumentation
opentelemetry-java-instrumentation copied to clipboard
feat(spring-mvc): Fallback to name Span including requestURI
Adding opentelemetry-spring-boot-starter defaults to create an instance of WebMvcTelemetryProducingFilter for Spring WebMvc Applications . This filter applies to all requests.
However, you only get "beautiful span names" for mappings of type RequestMappingHandlerMapping. I understand this is most likely related to the desire to group path patterns under a common span name.
For other, non RequestMappingHandlerMapping based requests, you get the bare HTTP method - e.g. GET for the span name.
Sure, the name WebMvc hints at Spring WebMvc, but the filter creates spans already. Besides, the code around it already does most of the wiring you want in more bare situations (e.g. Servlet).
Wouldn't it be reasonable to fallback to requestURI based paths, so we get GET /not-request-mapping-handler-mapping instead of GET span names when the request is not RequestMappingHandlerMapping based?
The attached patch does the trick for me.
hi @deas! span names need to have low cardinality, I think falling back to the full path could give unbounded cardinality?
check out https://github.com/open-telemetry/opentelemetry-specification/blob/65875014e15fa9739501413b3349961d503c0630/specification/trace/api.md?plain=1#L315-L316
Maybe we can make "default to request URI" opt-in for those how think they know what they are doing? ;)
I am using the filter with the OpenCMIS AtomPub Servlet at the moment. URI cardinality appears to be very low using the request URI. All the details are covered by the query string.