-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node): Add
tracePropagationTargets
option (#5521)
Co-authored-by: Lukas Stracke <[email protected]>
- Loading branch information
Showing
9 changed files
with
278 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
packages/node-integration-tests/suites/tracing/tracePropagationTargets/scenario.ts
This file contains 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 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import '@sentry/tracing'; | ||
|
||
import * as Sentry from '@sentry/node'; | ||
import * as http from 'http'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [new Sentry.Integrations.Http({ tracing: true })], | ||
}); | ||
|
||
const transaction = Sentry.startTransaction({ name: 'test_transaction' }); | ||
|
||
Sentry.configureScope(scope => { | ||
scope.setSpan(transaction); | ||
}); | ||
|
||
http.get('http://match-this-url.com/api/v0'); | ||
http.get('http://match-this-url.com/api/v1'); | ||
http.get('http://dont-match-this-url.com/api/v2'); | ||
http.get('http://dont-match-this-url.com/api/v3'); | ||
|
||
transaction.finish(); |
37 changes: 37 additions & 0 deletions
37
packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts
This file contains 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,37 @@ | ||
import nock from 'nock'; | ||
|
||
import { runScenario, runServer } from '../../../utils'; | ||
|
||
test('HttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async () => { | ||
const match1 = nock('http://match-this-url.com') | ||
.get('/api/v0') | ||
.matchHeader('baggage', val => typeof val === 'string') | ||
.matchHeader('sentry-trace', val => typeof val === 'string') | ||
.reply(200); | ||
|
||
const match2 = nock('http://match-this-url.com') | ||
.get('/api/v1') | ||
.matchHeader('baggage', val => typeof val === 'string') | ||
.matchHeader('sentry-trace', val => typeof val === 'string') | ||
.reply(200); | ||
|
||
const match3 = nock('http://dont-match-this-url.com') | ||
.get('/api/v2') | ||
.matchHeader('baggage', val => val === undefined) | ||
.matchHeader('sentry-trace', val => val === undefined) | ||
.reply(200); | ||
|
||
const match4 = nock('http://dont-match-this-url.com') | ||
.get('/api/v3') | ||
.matchHeader('baggage', val => val === undefined) | ||
.matchHeader('sentry-trace', val => val === undefined) | ||
.reply(200); | ||
|
||
const serverUrl = await runServer(__dirname); | ||
await runScenario(serverUrl); | ||
|
||
expect(match1.isDone()).toBe(true); | ||
expect(match2.isDone()).toBe(true); | ||
expect(match3.isDone()).toBe(true); | ||
expect(match4.isDone()).toBe(true); | ||
}); |
This file contains 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 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 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
Oops, something went wrong.