Repository navigation
fix(server-utils): Skip MongoDB statement serialization when the span is not recorded - #26826
Merged
Merged
Conversation
… is not recorded The Mongo integration scrubbed and stringified every command before the span was started, also when there was no parent span or the parent was not sampled. For commands with large write payloads this used a lot of CPU and memory. The statement is now built only when the active span records. scrubStatement also uses one loop instead of entries/map/reduce, to allocate less. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
size-limit report 📦Compared: eb217d9 (PR test merge using develop at 1f32728) Against: 1f32728 (develop) · base run #67760 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 3 not successful, 71 successful. See the run.
Successful checks
|
andreiborza
approved these changes
Nov 24, 2026
51 tasks done
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #26812
closes JS-4151
Description
This makes the Mongo integration build
db.query.textonly when the active span records. Without a parent span, or with a parent that is not sampled (for exampletracesSampleRate: 0), the command is no longer scrubbed and stringified.scrubStatementnow also uses one loop instead ofObject.entries/map/reduce, so it allocates less. The output is the same.FWIW we have something similar in CF:
sentry-javascript/packages/cloudflare/src/instrumentations/instrumentSqlStorage.ts
Line 45 in 1f32728
Why
The statement was built before the span was started, so each command paid the cost, also when no span was sent.
Benchmark
20 rounds of 5 parallel
updateOnecalls with a 3 MB nested document, no parent span,tracesSampleRate: 0, mongodb 7.1.0: