Skip to content
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

Root span names have a high cardinality #95

Open
svenwltr opened this issue Nov 10, 2022 · 0 comments
Open

Root span names have a high cardinality #95

svenwltr opened this issue Nov 10, 2022 · 0 comments

Comments

@svenwltr
Copy link

Root span names have a high cardinality, because they use the plain request URI:

$this->tracing->startActiveSpan(
$request->getUri(),
$options
);

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant