-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
14 changed files
with
544 additions
and
29 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
dev-packages/node-integration-tests/suites/tracing-new/httpIntegration/spans/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,21 @@ | ||
import '@sentry/tracing'; | ||
|
||
import * as http from 'http'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
integrations: [Sentry.httpIntegration({})], | ||
debug: true, | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
Sentry.startSpan({ name: 'test_transaction' }, async () => { | ||
http.get('http://match-this-url.com/api/v0'); | ||
http.get('http://match-this-url.com/api/v1'); | ||
|
||
// Give it a tick to resolve... | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
}); |
40 changes: 40 additions & 0 deletions
40
dev-packages/node-integration-tests/suites/tracing-new/httpIntegration/spans/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 nock from 'nock'; | ||
|
||
import { TestEnv, assertSentryTransaction } from '../../../../utils'; | ||
|
||
test('should capture spans for outgoing http requests', async () => { | ||
const match1 = nock('http://match-this-url.com').get('/api/v0').reply(200); | ||
const match2 = nock('http://match-this-url.com').get('/api/v1').reply(200); | ||
|
||
const env = await TestEnv.init(__dirname); | ||
const envelope = await env.getEnvelopeRequest({ envelopeType: 'transaction' }); | ||
|
||
expect(match1.isDone()).toBe(true); | ||
expect(match2.isDone()).toBe(true); | ||
|
||
expect(envelope).toHaveLength(3); | ||
|
||
assertSentryTransaction(envelope[2], { | ||
transaction: 'test_transaction', | ||
spans: [ | ||
{ | ||
description: 'GET http://match-this-url.com/api/v0', | ||
op: 'http.client', | ||
origin: 'auto.http.node.http', | ||
status: 'ok', | ||
tags: { | ||
'http.status_code': '200', | ||
}, | ||
}, | ||
{ | ||
description: 'GET http://match-this-url.com/api/v1', | ||
op: 'http.client', | ||
origin: 'auto.http.node.http', | ||
status: 'ok', | ||
tags: { | ||
'http.status_code': '200', | ||
}, | ||
}, | ||
], | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
...kages/node-integration-tests/suites/tracing-new/httpIntegration/spansDisabled/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 '@sentry/tracing'; | ||
|
||
import * as http from 'http'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
integrations: [Sentry.httpIntegration({ tracing: false })], | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
Sentry.startSpan({ name: 'test_transaction' }, async () => { | ||
http.get('http://match-this-url.com/api/v0'); | ||
http.get('http://match-this-url.com/api/v1'); | ||
|
||
// Give it a tick to resolve... | ||
await new Promise(resolve => setTimeout(resolve, 100)); | ||
}); |
21 changes: 21 additions & 0 deletions
21
dev-packages/node-integration-tests/suites/tracing-new/httpIntegration/spansDisabled/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,21 @@ | ||
import nock from 'nock'; | ||
|
||
import { TestEnv, assertSentryTransaction } from '../../../../utils'; | ||
|
||
test('should not capture spans for outgoing http requests if tracing is disabled', async () => { | ||
const match1 = nock('http://match-this-url.com').get('/api/v0').reply(200); | ||
const match2 = nock('http://match-this-url.com').get('/api/v1').reply(200); | ||
|
||
const env = await TestEnv.init(__dirname); | ||
const envelope = await env.getEnvelopeRequest({ envelopeType: 'transaction' }); | ||
|
||
expect(match1.isDone()).toBe(true); | ||
expect(match2.isDone()).toBe(true); | ||
|
||
expect(envelope).toHaveLength(3); | ||
|
||
assertSentryTransaction(envelope[2], { | ||
transaction: 'test_transaction', | ||
spans: [], | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
...-integration-tests/suites/tracing-new/httpIntegration/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,20 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import '@sentry/tracing'; | ||
|
||
import * as http from 'http'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [Sentry.httpIntegration({})], | ||
}); | ||
|
||
Sentry.startSpan({ name: 'test_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'); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...node-integration-tests/suites/tracing-new/httpIntegration/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,42 @@ | ||
import nock from 'nock'; | ||
|
||
import { TestEnv, runScenario } from '../../../../utils'; | ||
|
||
test('httpIntegration should instrument correct requests when tracePropagationTargets option is provided & tracing is enabled', 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 env = await TestEnv.init(__dirname); | ||
await runScenario(env.url); | ||
|
||
env.server.close(); | ||
nock.cleanAll(); | ||
|
||
await new Promise(resolve => env.server.close(resolve)); | ||
|
||
expect(match1.isDone()).toBe(true); | ||
expect(match2.isDone()).toBe(true); | ||
expect(match3.isDone()).toBe(true); | ||
expect(match4.isDone()).toBe(true); | ||
}); |
19 changes: 19 additions & 0 deletions
19
...tion-tests/suites/tracing-new/httpIntegration/tracePropagationTargetsDisabled/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,19 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import '@sentry/tracing'; | ||
|
||
import * as http from 'http'; | ||
import * as Sentry from '@sentry/node'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
tracePropagationTargets: [/\/v0/, 'v1'], | ||
integrations: [Sentry.httpIntegration({})], | ||
}); | ||
|
||
Sentry.startSpan({ name: 'test_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'); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...egration-tests/suites/tracing-new/httpIntegration/tracePropagationTargetsDisabled/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,42 @@ | ||
import nock from 'nock'; | ||
|
||
import { TestEnv, runScenario } from '../../../../utils'; | ||
|
||
test('httpIntegration should not instrument when tracing is enabled', async () => { | ||
const match1 = nock('http://match-this-url.com') | ||
.get('/api/v0') | ||
.matchHeader('baggage', val => val === undefined) | ||
.matchHeader('sentry-trace', val => val === undefined) | ||
.reply(200); | ||
|
||
const match2 = nock('http://match-this-url.com') | ||
.get('/api/v1') | ||
.matchHeader('baggage', val => val === undefined) | ||
.matchHeader('sentry-trace', val => val === undefined) | ||
.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 env = await TestEnv.init(__dirname); | ||
await runScenario(env.url); | ||
|
||
env.server.close(); | ||
nock.cleanAll(); | ||
|
||
await new Promise(resolve => env.server.close(resolve)); | ||
|
||
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
Oops, something went wrong.