Skip to content

feat(attributes): Add sentry.normalized_db_query - #194

Merged
Ahmed-Labs merged 3 commits into
mainfrom
ahmed/feat/add-normalized-db-query-sentry-attribute
Nov 20, 2025
Merged

feat(attributes): Add sentry.normalized_db_query#194
Ahmed-Labs merged 3 commits into
mainfrom
ahmed/feat/add-normalized-db-query-sentry-attribute

Conversation

@Ahmed-Labs

Copy link
Copy Markdown
Contributor

Description

Introduces a new sentry attribute sentry.normalized_db_query. In the V1 span Relay pipeline, we read the raw db query from the span description field, scrub it, and write it back to the description field (which becomes sentry.normalized_description).

Now that we're migrating to V2 spans, we plan on reading the query from the conventional field db.query.text, normalizing it, and writing it to another field (instead of overwriting the raw original field). However, there is currently no appropriate field to use for the normalized query.

@github-actions

github-actions Bot commented Nov 19, 2025

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 07e210e

@Ahmed-Labs Ahmed-Labs changed the title feat: Add normalized_db_query Sentry attribute feat(attributes): Add normalized_db_query Sentry attribute Nov 19, 2025
@Ahmed-Labs Ahmed-Labs changed the title feat(attributes): Add normalized_db_query Sentry attribute feat(attributes): Add sentry.normalized_db_query Nov 19, 2025
@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/add-normalized-db-query-sentry-attribute branch from f1d4186 to 07e210e Compare November 19, 2025 16:18
@Ahmed-Labs
Ahmed-Labs marked this pull request as ready for review November 19, 2025 16:26
@cleptric

Copy link
Copy Markdown
Member

We might want to mark this as deprecated then and add a back-fill property to let Relay write it into the correct field. cc @loewenheim

@loewenheim

Copy link
Copy Markdown
Contributor

What attribute would it be backfilled to?

@mjq

mjq commented Nov 19, 2025

Copy link
Copy Markdown
Member

@cleptric

We might want to mark this as deprecated then and add a back-fill property to let Relay write it into the correct field.

sentry.normalized_description currently holds several different types of values, depending on the type of span (op). So, this isn't a 1:1 replacement. We'll similarly move the other types of values into their own semantic attributes.

@cleptric

Copy link
Copy Markdown
Member

Ok, I think I understand. So db.query.text, while it should be already sanitized (https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext), might not be, so we sanitize it again and use sentry.normalized_db_query in the product. And our SDKs will send db.query.text.

@Ahmed-Labs

Copy link
Copy Markdown
Contributor Author

Ok, I think I understand. So db.query.text, while it should be already sanitized (https://opentelemetry.io/docs/specs/semconv/database/database-spans/#sanitization-of-dbquerytext), might not be, so we sanitize it again and use sentry.normalized_db_query in the product. And our SDKs will send db.query.text.

Yup! Relay would just add this field so it can be used in the product.

db.query.text shouldn't actually be pre-sanitized, it should contain the raw query. We just normalize the raw query for the sake of grouping in the product side (e.g. backend insights). V1 spans contained the raw query in the span description field, and relay normalizes/scrubs it. Now, we'd like to undergo the same normalization for V2 spans, except the raw query is in db.query.text but we don't want to write it back to the same field, and instead to this new field (so we can preserve the raw query).

@Ahmed-Labs
Ahmed-Labs merged commit bd6a5fa into main Nov 20, 2025
11 checks passed
@Ahmed-Labs
Ahmed-Labs deleted the ahmed/feat/add-normalized-db-query-sentry-attribute branch November 20, 2025 14:45
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

Successfully merging this pull request may close these issues.

4 participants