Skip to content

Commit 5caec05

Browse files
authored
feat(node): Add tracing without performance to Node http integration (#8450)
Updates the Node HTTP integration to always attach `sentry-trace` headers to outgoing requests. This can be controlled with the top level `tracePropagationOptions` option.
1 parent 81baae6 commit 5caec05

File tree

15 files changed

+246
-123
lines changed

15 files changed

+246
-123
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ jobs:
661661
needs: [job_get_metadata, job_build]
662662
if: needs.job_get_metadata.outputs.changed_node == 'true' || github.event_name != 'pull_request'
663663
runs-on: ubuntu-20.04
664-
timeout-minutes: 10
664+
timeout-minutes: 15
665665
strategy:
666666
fail-fast: false
667667
matrix:

packages/nextjs/test/integration/sentry.client.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Integrations } from '@sentry/tracing';
33

44
Sentry.init({
55
dsn: 'https://[email protected]/1337',
6-
tracesSampleRate: 1,
6+
tracesSampler: () => true,
77
debug: process.env.SDK_DEBUG,
88

99
integrations: [

packages/nextjs/test/integration/sentry.edge.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
dsn: 'https://[email protected]/1337',
5-
tracesSampleRate: 1,
5+
tracesSampleRate: 1.0,
6+
tracePropagationTargets: ['http://example.com'],
67
debug: process.env.SDK_DEBUG,
78
});

packages/nextjs/test/integration/sentry.server.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
dsn: 'https://[email protected]/1337',
5-
tracesSampleRate: 1,
5+
tracesSampleRate: 1.0,
6+
tracePropagationTargets: ['http://example.com'],
67
debug: process.env.SDK_DEBUG,
78

89
integrations: defaults => [

packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Sentry.init({
1212
dsn: 'https://[email protected]/1337',
1313
release: '1.0',
1414
environment: 'prod',
15+
tracePropagationTargets: [/^(?!.*express).*$/],
1516
// eslint-disable-next-line deprecation/deprecation
1617
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1718
tracesSampleRate: 1.0,

packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Sentry.init({
1212
dsn: 'https://[email protected]/1337',
1313
release: '1.0',
1414
environment: 'prod',
15+
// disable requests to /express
16+
tracePropagationTargets: [/^(?!.*express).*$/],
1517
// eslint-disable-next-line deprecation/deprecation
1618
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1719
tracesSampleRate: 1.0,

packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Sentry.init({
1212
dsn: 'https://[email protected]/1337',
1313
release: '1.0',
1414
environment: 'prod',
15+
// disable requests to /express
16+
tracePropagationTargets: [/^(?!.*express).*$/],
1517
// eslint-disable-next-line deprecation/deprecation
1618
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1719
tracesSampleRate: 1.0,

packages/node-integration-tests/suites/express/sentry-trace/baggage-transaction-name/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Sentry.init({
1212
dsn: 'https://[email protected]/1337',
1313
release: '1.0',
1414
environment: 'prod',
15+
// disable requests to /express
16+
tracePropagationTargets: [/^(?!.*express).*$/],
1517
// eslint-disable-next-line deprecation/deprecation
1618
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1719
tracesSampleRate: 1.0,

packages/node-integration-tests/suites/express/sentry-trace/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Sentry.init({
1212
dsn: 'https://[email protected]/1337',
1313
release: '1.0',
1414
environment: 'prod',
15+
tracePropagationTargets: [/^(?!.*express).*$/],
1516
// eslint-disable-next-line deprecation/deprecation
1617
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1718
tracesSampleRate: 1.0,

packages/node-integration-tests/suites/express/tracing/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const app = express();
77
Sentry.init({
88
dsn: 'https://[email protected]/1337',
99
release: '1.0',
10+
// disable attaching headers to /test/* endpoints
11+
tracePropagationTargets: [/^(?!.*test).*$/],
1012
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Sentry.Integrations.Express({ app })],
1113
tracesSampleRate: 1.0,
1214
});

packages/node-integration-tests/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ export class TestEnv {
202202
*/
203203
public async getAPIResponse(
204204
url?: string,
205-
headers?: Record<string, string>,
205+
headers: Record<string, string> = {},
206206
endServer: boolean = true,
207207
): Promise<unknown> {
208208
try {
209-
const { data } = await axios.get(url || this.url, { headers: headers || {} });
209+
const { data } = await axios.get(url || this.url, { headers });
210210
return data;
211211
} finally {
212212
await Sentry.flush();

0 commit comments

Comments
 (0)