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

Prevent high cardinality in span names #38

Open
chazapp opened this issue Oct 29, 2024 · 1 comment
Open

Prevent high cardinality in span names #38

chazapp opened this issue Oct 29, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chazapp
Copy link

chazapp commented Oct 29, 2024

Describe the problem

The Tyk Gateway OpenTelemetry implementation generates high cardinality span names, from this line of code:

var httpSpanNameFormatter = func(operation string, r *http.Request) string {
return r.Method + " " + r.URL.Path
}

This code can create span names containing URI data with high cardinality, such as:

 GET /service/v1/foo/E97AF021-B82C-4EF3-9A2C-BF49EF04CCD8/bar

OpenTelemetry's Semantic Conventions for HTTP Spans clearly states:

HTTP span names SHOULD be {method} {target} if there is a (low-cardinality) target available. If there is no (low-cardinality) {target} available, HTTP span names SHOULD be {method}.

Instrumentation MUST NOT default to using URI path as a {target}.

Describe the solution you'd like

The issue can be solved in different ways. Here are a few ideas:

Change the span name to `{method}` Per OpenTelemetry convention, if finding a low-cardinality target is not possible, set the span name to the HTTP method only.
Change the span name to `{method} {apiName}` Either via context or parsing, use only the downstream API name.
Allow a pattern to be passed via config The span name could be formed using a pattern that would be user provided from API configuration.

Describe alternatives you've considered

I can use OTEL-Collector transform processor to edit spans before they reach my storage backend, but I'd rather see the issue fixed upstream, in the span creator, respecting Open Telemetry conventions.

@chazapp chazapp added the enhancement New feature or request label Oct 29, 2024
@tbuchaillot
Copy link
Collaborator

tbuchaillot commented Nov 29, 2024

The span name could be formed using a pattern that would be user provided from API configuration.

I think we should definitely go with this options since any of the others will mean a breaking change for existing users.

@tbuchaillot tbuchaillot added the good first issue Good for newcomers label Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants