-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(tracing): Add dynamic sampling correlation context data to envelope header #3062
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
lobsterkatie
merged 3 commits into
kmclb-dynamic-sampling-data-in-envelopes
from
kmclb-correlation-trace-context-in-envelope-header-poc
Nov 24, 2020
Merged
Changes from all commits
Commits
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
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,65 @@ | ||
import { Event } from '@sentry/types'; | ||
|
||
import { API } from '../../src/api'; | ||
import { eventToSentryRequest } from '../../src/request'; | ||
|
||
describe('eventToSentryRequest', () => { | ||
const api = new API('https://[email protected]/12312012'); | ||
|
||
it('correctly handles error/message events', () => { | ||
const event = { | ||
event_id: '1231201211212012', | ||
exception: { values: [{ type: 'PuppyProblemsError', value: 'Charlie ate the flip-flops :-(' }] }, | ||
user: { id: '1121', username: 'CharlieDog', ip_address: '11.21.20.12' }, | ||
}; | ||
|
||
const result = eventToSentryRequest(event, api); | ||
expect(result.type).toEqual('event'); | ||
expect(result.url).toEqual( | ||
'https://squirrelchasers.ingest.sentry.io/api/12312012/store/?sentry_key=dogsarebadatkeepingsecrets&sentry_version=7', | ||
); | ||
expect(result.body).toEqual(JSON.stringify(event)); | ||
}); | ||
|
||
it('correctly handles transaction events', () => { | ||
const eventId = '1231201211212012'; | ||
const traceId = '0908201304152013'; | ||
const event = { | ||
contexts: { trace: { trace_id: traceId, span_id: '12261980', op: 'pageload' } }, | ||
environment: 'dogpark', | ||
event_id: eventId, | ||
release: 'off.leash.park', | ||
spans: [], | ||
transaction: '/dogs/are/great/', | ||
type: 'transaction', | ||
user: { id: '1121', username: 'CharlieDog', ip_address: '11.21.20.12' }, | ||
}; | ||
|
||
const result = eventToSentryRequest(event as Event, api); | ||
|
||
const [envelopeHeaderString, itemHeaderString, eventString] = result.body.split('\n'); | ||
|
||
const envelope = { | ||
envelopeHeader: JSON.parse(envelopeHeaderString), | ||
itemHeader: JSON.parse(itemHeaderString), | ||
event: JSON.parse(eventString), | ||
}; | ||
|
||
expect(result.type).toEqual('transaction'); | ||
expect(result.url).toEqual( | ||
'https://squirrelchasers.ingest.sentry.io/api/12312012/envelope/?sentry_key=dogsarebadatkeepingsecrets&sentry_version=7', | ||
); | ||
expect(envelope.envelopeHeader).toEqual({ | ||
event_id: eventId, | ||
sent_at: expect.any(String), | ||
trace: { | ||
environment: 'dogpark', | ||
public_key: 'dogsarebadatkeepingsecrets', | ||
release: 'off.leash.park', | ||
trace_id: traceId, | ||
}, | ||
}); | ||
expect(envelope.itemHeader).toEqual({ type: 'transaction' }); | ||
expect(envelope.event).toEqual(event); | ||
}); | ||
}); |
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.
Uh oh!
There was an error while loading. Please reload this page.