OpentracingBundle-core
OpentracingBundle-core copied to clipboard
Root span names have a high cardinality
Root span names have a high cardinality, because they use the plain request URI:
https://github.com/auxmoney/OpentracingBundle-core/blob/2cbf03e7d6d94f87274b3cb352ae0428cb58cf7e/EventListener/StartRootSpanSubscriber.php#L61-L64
The names should be more generic according to the docs of OpenTelemetry (which is the successor of OpenTracing):
The span name SHOULD be the most general string that identifies a (statistically) interesting class of Spans, rather than individual Span instances while still being human-readable. That is, “get_user” is a reasonable name, while “get_user/314159”, where “314159” is a user ID, is not a good name due to its high cardinality. Generality SHOULD be prioritized over human-readability. — https://opentelemetry.io/docs/reference/specification/trace/api/#span
and:
Many REST APIs encode parameters into URI path, e.g. /api/users/123 where 123 is a user id, which creates high cardinality value space not suitable for span names. In case of HTTP servers, these endpoints are often mapped by the server frameworks to more concise HTTP routes, e.g. /api/users/{user_id}, which are recommended as the low cardinality span names. — https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/http/#name
I think using the plain URL also might put necessary stress to the Tracing systems.
As an alternative we could replace the URL we with the route name as soon as it is available in the KernelEvents::CONTROLLER
event ($event->getRequest()->attributes->get('_route')
.
Thank you!