-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(core): Normalize trace context #5171
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f51fe68
fix(core): Normalize trace context
6720cca
Normalize free form data in spans
37691cd
Add integration tests
2ff6337
Fix tests
febd6cd
Add documentation
7ec680f
Fix bug in `dropUndefinedKeys` that kept references to original data
0256842
Undo changes to `dropUndefinedKeys`
4d6a919
Fix rebasing stuff
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
packages/integration-tests/suites/public-api/startTransaction/circular_data/subject.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const chicken = {}; | ||
const egg = { contains: chicken }; | ||
chicken.lays = egg; | ||
|
||
const circularObject = chicken; | ||
lforst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const transaction = Sentry.startTransaction({ name: 'circular_object_test_transaction', data: circularObject }); | ||
const span = transaction.startChild({ op: 'circular_object_test_span', data: circularObject }); | ||
|
||
span.finish(); | ||
transaction.finish(); |
26 changes: 26 additions & 0 deletions
26
packages/integration-tests/suites/public-api/startTransaction/circular_data/test.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect } from '@playwright/test'; | ||
import { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; | ||
|
||
sentryTest('should be able to handle circular data', async ({ getLocalTestPath, page }) => { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url); | ||
|
||
expect(eventData.type).toBe('transaction'); | ||
expect(eventData.transaction).toBe('circular_object_test_transaction'); | ||
|
||
expect(eventData.contexts).toMatchObject({ | ||
trace: { | ||
data: { lays: { contains: '[Circular ~]' } }, | ||
}, | ||
}); | ||
|
||
expect(eventData?.spans?.[0]).toMatchObject({ | ||
data: { lays: { contains: '[Circular ~]' } }, | ||
op: 'circular_object_test_span', | ||
}); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 2000)); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ window.Sentry = Sentry; | |
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
tracesSampleRate: 1.0, | ||
normalizeDepth: 10, | ||
}); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we gate this with a tracing debug flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't do that. The tracing flag currently only guards code that sets up automatic instrumentation, i.e. side effect code that makes use of tracing. This allows tracing to be treeshaken if it's not in use. It can still be used, even if the flag is set to false. If we guard this here and users call
startTransaction
and pass in circular data, they're not gonna have a good time. Good consideration though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!