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

Normalize "IN(?, ?, ...)" substrings in db.statement span attribute to "IN(?)" #10442

Closed
swar8080 opened this issue Feb 8, 2024 · 3 comments · Fixed by #10564
Closed

Normalize "IN(?, ?, ...)" substrings in db.statement span attribute to "IN(?)" #10442

swar8080 opened this issue Feb 8, 2024 · 3 comments · Fixed by #10564
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request

Comments

@swar8080
Copy link
Contributor

swar8080 commented Feb 8, 2024

Is your feature request related to a problem? Please describe.

Hello, we're looking to use db.statement as an attribute in span metrics to get RED metrics for each query

Currently, SQL queries using IN with a variable number of values will each generate a different db.statement, varying only by the number of ? in the IN part. That can cause high cardinality span metrics and makes the metrics difficult to analyze

Describe the solution you'd like

Replace all IN(...) statements in SQL db.statements with a constant value like IN( ? )

Describe alternatives you've considered

Using the otel collector to normalize the query string

Additional context

Let me know if this would need to first be approved as a semantic convention

@swar8080 swar8080 added enhancement New feature or request needs triage New issue that requires triage labels Feb 8, 2024
@trask
Copy link
Member

trask commented Feb 8, 2024

this makes sense to me

possibly IN(?, ...) to be more explicit that it could be one or more elements

Let me know if this would need to first be approved as a semantic convention

I don't think so, as there's no specification for how to normalize queries at this point

@trask trask added contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome and removed needs triage New issue that requires triage labels Feb 8, 2024
@laurit
Copy link
Contributor

laurit commented Feb 8, 2024

possibly IN(?, ...) to be more explicit that it could be one or more elements

I suspect that backends might attempt to parse these queries so it might be better to ensure that normalization does not introduce syntax errors

@swar8080
Copy link
Contributor Author

swar8080 commented Feb 8, 2024

Would this new behaviour need to be turned on with configuration or a feature flag? Just wondering in case I or someone else ends up implementing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome Request makes sense, maintainers probably won't have time, contribution would be welcome enhancement New feature or request
Projects
None yet
3 participants