-
-
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.
- Loading branch information
Showing
18 changed files
with
370 additions
and
39 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
dev-packages/node-integration-tests/suites/tracing/requests/fetch-noSampleRate/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,24 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [], | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
await fetch(`${process.env.SERVER_URL}/api/v0`); | ||
await fetch(`${process.env.SERVER_URL}/api/v1`); | ||
await fetch(`${process.env.SERVER_URL}/api/v2`); | ||
await fetch(`${process.env.SERVER_URL}/api/v3`); | ||
|
||
Sentry.captureException(new Error('foo')); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
53 changes: 53 additions & 0 deletions
53
dev-packages/node-integration-tests/suites/tracing/requests/fetch-noSampleRate/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,53 @@ | ||
import { conditionalTest } from '../../../../utils'; | ||
import { createRunner } from '../../../../utils/runner'; | ||
import { createTestServer } from '../../../../utils/server'; | ||
|
||
conditionalTest({ min: 18 })('outgoing fetch', () => { | ||
test('outgoing fetch requests are correctly instrumented without tracesSampleRate', done => { | ||
expect.assertions(15); | ||
|
||
createTestServer(done) | ||
.get('/api/v0', headers => { | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['__requestUrl']).toBeUndefined(); | ||
}) | ||
.get('/api/v1', headers => { | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['__requestUrl']).toBeUndefined(); | ||
}) | ||
.get('/api/v2', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
expect(headers['__requestUrl']).toBeUndefined(); | ||
}) | ||
.get('/api/v3', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
expect(headers['__requestUrl']).toBeUndefined(); | ||
}) | ||
.start() | ||
.then(SERVER_URL => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.withEnv({ SERVER_URL }) | ||
.ensureNoErrorOutput() | ||
.ignore('session', 'sessions') | ||
.expect({ | ||
event: { | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'foo', | ||
}, | ||
], | ||
}, | ||
}, | ||
}) | ||
.start(done); | ||
}); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled/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,25 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [], | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
await Sentry.startSpan({ name: 'test_span' }, async () => { | ||
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
await fetch(`${process.env.SERVER_URL}/api/v0`); | ||
await fetch(`${process.env.SERVER_URL}/api/v1`); | ||
await fetch(`${process.env.SERVER_URL}/api/v2`); | ||
await fetch(`${process.env.SERVER_URL}/api/v3`); | ||
}); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
40 changes: 40 additions & 0 deletions
40
dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled/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,40 @@ | ||
import { conditionalTest } from '../../../../utils'; | ||
import { createRunner } from '../../../../utils/runner'; | ||
import { createTestServer } from '../../../../utils/server'; | ||
|
||
conditionalTest({ min: 18 })('outgoing fetch', () => { | ||
test('outgoing sampled fetch requests are correctly instrumented xxx', done => { | ||
expect.assertions(11); | ||
|
||
createTestServer(done) | ||
.get('/api/v0', headers => { | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
}) | ||
.get('/api/v1', headers => { | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
}) | ||
.get('/api/v2', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.get('/api/v3', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.start() | ||
.then(SERVER_URL => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.withEnv({ SERVER_URL }) | ||
.expect({ | ||
transaction: { | ||
// we're not too concerned with the actual transaction here since this is tested elsewhere | ||
}, | ||
}) | ||
.start(done); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/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,28 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
tracesSampleRate: 0, | ||
integrations: [], | ||
transport: loggingTransport, | ||
}); | ||
|
||
async function run(): Promise<void> { | ||
// Wrap in span that is not sampled | ||
await Sentry.startSpan({ name: 'outer' }, async () => { | ||
// Since fetch is lazy loaded, we need to wait a bit until it's fully instrumented | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
await fetch(`${process.env.SERVER_URL}/api/v0`); | ||
await fetch(`${process.env.SERVER_URL}/api/v1`); | ||
await fetch(`${process.env.SERVER_URL}/api/v2`); | ||
await fetch(`${process.env.SERVER_URL}/api/v3`); | ||
}); | ||
|
||
Sentry.captureException(new Error('foo')); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
48 changes: 48 additions & 0 deletions
48
dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/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,48 @@ | ||
import { conditionalTest } from '../../../../utils'; | ||
import { createRunner } from '../../../../utils/runner'; | ||
import { createTestServer } from '../../../../utils/server'; | ||
|
||
conditionalTest({ min: 18 })('outgoing fetch', () => { | ||
test('outgoing fetch requests are correctly instrumented when not sampled', done => { | ||
expect.assertions(11); | ||
|
||
createTestServer(done) | ||
.get('/api/v0', headers => { | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
}) | ||
.get('/api/v1', headers => { | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
}) | ||
.get('/api/v2', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.get('/api/v3', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.start() | ||
.then(SERVER_URL => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.withEnv({ SERVER_URL }) | ||
.ignore('session', 'sessions') | ||
.expect({ | ||
event: { | ||
exception: { | ||
values: [ | ||
{ | ||
type: 'Error', | ||
value: 'foo', | ||
}, | ||
], | ||
}, | ||
}, | ||
}) | ||
.start(done); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...uites/tracing/tracingNoSampleRate/test.ts → ...racing/requests/http-noSampleRate/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
20 changes: 20 additions & 0 deletions
20
dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/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,20 @@ | ||
import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [], | ||
transport: loggingTransport, | ||
}); | ||
|
||
import * as http from 'http'; | ||
|
||
Sentry.startSpan({ name: 'test_span' }, () => { | ||
http.get(`${process.env.SERVER_URL}/api/v0`); | ||
http.get(`${process.env.SERVER_URL}/api/v1`); | ||
http.get(`${process.env.SERVER_URL}/api/v2`); | ||
http.get(`${process.env.SERVER_URL}/api/v3`); | ||
}); |
37 changes: 37 additions & 0 deletions
37
dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/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 { createRunner } from '../../../../utils/runner'; | ||
import { createTestServer } from '../../../../utils/server'; | ||
|
||
test('outgoing sampled http requests are correctly instrumented', done => { | ||
expect.assertions(11); | ||
|
||
createTestServer(done) | ||
.get('/api/v0', headers => { | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); | ||
}) | ||
.get('/api/v1', headers => { | ||
expect(headers['baggage']).toEqual(expect.any(String)); | ||
expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); | ||
expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); | ||
}) | ||
.get('/api/v2', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.get('/api/v3', headers => { | ||
expect(headers['baggage']).toBeUndefined(); | ||
expect(headers['sentry-trace']).toBeUndefined(); | ||
}) | ||
.start() | ||
.then(SERVER_URL => { | ||
createRunner(__dirname, 'scenario.ts') | ||
.withEnv({ SERVER_URL }) | ||
.expect({ | ||
transaction: { | ||
// we're not too concerned with the actual transaction here since this is tested elsewhere | ||
}, | ||
}) | ||
.start(done); | ||
}); | ||
}); |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...s/suites/tracing/tracingUnsampled/test.ts → ...s/tracing/requests/http-unsampled/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
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.