Skip to content

feat(spanv2): Add db attribute normalization - #5399

Merged
Ahmed-Labs merged 17 commits into
masterfrom
ahmed/feat/use-sentry-conventions-for-span-field-scrubbing
Nov 25, 2025
Merged

Ahmed-Labs merged 17 commits into
masterfrom
ahmed/feat/use-sentry-conventions-for-span-field-scrubbing

Conversation

@Ahmed-Labs

@Ahmed-Labs Ahmed-Labs commented Nov 20, 2025 •

Copy link
Copy Markdown
Contributor

In V1 spans, normalization of any type of span happens in the description field. So in the case of db spans, relay expects the db query to be stored in the description field, which it reads, normalizes, and writes to a normalized description field.

This PR begins to migrate this normalization logic to V2 spans. But in the case of V2 spans, we expect the SDKs/Otel to send attributes in their corresponding fields as opposed to just using the description field. For instance, this means that we no longer expect a db query to be stored in description, and instead it should be in the db.query.text field. To start migrating normalization, this PR tackles the normalization of db related attributes.

The actual logic for normalization is extracted from the SpanV1 tag extraction function and the description scrubbing function.

Note: This branch is stacked on top of another PR that bumps the version of sentry-conventions, introducing one of the fields I use here to store the normalized db query sentry.normalized_db_query. So you can ignore that the sentry convention bump is included here, this branch will be rebased once that PR is merged.

@Ahmed-Labs
Ahmed-Labs requested a review from mjq November 20, 2025 21:29
@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch from 1650016 to ee9d220 Compare November 21, 2025 20:01
@Ahmed-Labs Ahmed-Labs changed the title feat(spanv2): Add db query text normalization feat(spanv2): Add db attribute normalization Nov 21, 2025
@Ahmed-Labs
Ahmed-Labs marked this pull request as ready for review November 24, 2025 14:24
@Ahmed-Labs
Ahmed-Labs requested a review from a team as a code owner November 24, 2025 14:24
@Ahmed-Labs
Ahmed-Labs removed the request for review from mjq November 24, 2025 15:33
@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch from 4189733 to db55137 Compare November 24, 2025 17:52
Comment thread relay-conventions/src/consts.rs Resolved
@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch 2 times, most recently from 9716023 to 7051a5c Compare November 24, 2025 20:39
@Ahmed-Labs

Copy link
Copy Markdown
Contributor Author

@Dav1dde Thanks for the review! 🙏 Addressed all your comments, let me know if there's anything else I should update.

@Dav1dde Dav1dde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, looks good!

It'd be great if you can add or modify an existing integration test in test_spansv2.py or test_spansv2_otel.py` to also send some database attributes to just assert that normalization actually happens and is called.

It should be enough if you just add some attributes to a basic test.

@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch from ec5c538 to 6f1f0c0 Compare November 25, 2025 16:46
@Ahmed-Labs
Ahmed-Labs force-pushed the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch from fb8818f to 19135aa Compare November 25, 2025 20:56
@Ahmed-Labs
Ahmed-Labs enabled auto-merge November 25, 2025 20:56
@Ahmed-Labs
Ahmed-Labs disabled auto-merge November 25, 2025 21:13
@Ahmed-Labs
Ahmed-Labs added this pull request to the merge queue Nov 25, 2025
Merged via the queue into master with commit 411826f Nov 25, 2025
@Ahmed-Labs
Ahmed-Labs deleted the ahmed/feat/use-sentry-conventions-for-span-field-scrubbing branch November 25, 2025 21:52
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.

3 participants