Skip to content

Commit

Permalink
feat(node): Add tracing without performance to Node http integration (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
AbhiPrasad committed Jul 11, 2023
1 parent 81baae6 commit 5caec05
Show file tree
Hide file tree
Showing 15 changed files with 246 additions and 123 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ jobs:
needs: [job_get_metadata, job_build]
if: needs.job_get_metadata.outputs.changed_node == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-20.04
timeout-minutes: 10
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Integrations } from '@sentry/tracing';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1,
tracesSampler: () => true,
debug: process.env.SDK_DEBUG,

integrations: [
Expand Down
3 changes: 2 additions & 1 deletion packages/nextjs/test/integration/sentry.edge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1,
tracesSampleRate: 1.0,
tracePropagationTargets: ['http://example.com'],
debug: process.env.SDK_DEBUG,
});
3 changes: 2 additions & 1 deletion packages/nextjs/test/integration/sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as Sentry from '@sentry/nextjs';

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
tracesSampleRate: 1,
tracesSampleRate: 1.0,
tracePropagationTargets: ['http://example.com'],
debug: process.env.SDK_DEBUG,

integrations: defaults => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
environment: 'prod',
tracePropagationTargets: [/^(?!.*express).*$/],
// eslint-disable-next-line deprecation/deprecation
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
environment: 'prod',
// disable requests to /express
tracePropagationTargets: [/^(?!.*express).*$/],
// eslint-disable-next-line deprecation/deprecation
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
environment: 'prod',
// disable requests to /express
tracePropagationTargets: [/^(?!.*express).*$/],
// eslint-disable-next-line deprecation/deprecation
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
environment: 'prod',
// disable requests to /express
tracePropagationTargets: [/^(?!.*express).*$/],
// eslint-disable-next-line deprecation/deprecation
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
environment: 'prod',
tracePropagationTargets: [/^(?!.*express).*$/],
// eslint-disable-next-line deprecation/deprecation
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
tracesSampleRate: 1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const app = express();
Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
// disable attaching headers to /test/* endpoints
tracePropagationTargets: [/^(?!.*test).*$/],
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Sentry.Integrations.Express({ app })],
tracesSampleRate: 1.0,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/node-integration-tests/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ export class TestEnv {
*/
public async getAPIResponse(
url?: string,
headers?: Record<string, string>,
headers: Record<string, string> = {},
endServer: boolean = true,
): Promise<unknown> {
try {
const { data } = await axios.get(url || this.url, { headers: headers || {} });
const { data } = await axios.get(url || this.url, { headers });
return data;
} finally {
await Sentry.flush();
Expand Down

0 comments on commit 5caec05

Please sign in to comment.