-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Support propagateTraceparent
#18476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
timfish
wants to merge
15
commits into
develop
Choose a base branch
from
timfish/feat/node-propagateTraceparent
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+263
−29
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9c2ebf3
feat(node): Support `propagateTraceparent`
timfish 2abba7d
Merge branch 'develop' into timfish/feat/node-propagateTraceparent
timfish 80d5f5e
less otel changes
timfish 805f8dc
Merge branch 'timfish/feat/node-propagateTraceparent' of github.com:g…
timfish c448386
Revert
timfish 89f1ee2
Test http
timfish d9fa8ba
More tests and bump size limit
timfish 4132f4a
Working?
timfish 51b1b89
Fix
timfish 025b5af
Merge remote-tracking branch 'upstream/develop' into timfish/feat/nod…
timfish 4134dab
Improve logic
timfish 3cd6b36
Include in fields
timfish 8ce9ede
Oops
timfish b0c4b09
Merge branch 'develop' into timfish/feat/node-propagateTraceparent
timfish 87d04c4
Merge branch 'develop' into timfish/feat/node-propagateTraceparent
timfish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
dev-packages/node-core-integration-tests/suites/tracing/requests/traceparent/instrument.mjs
This file contains hidden or 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,13 @@ | ||
| import * as Sentry from '@sentry/node-core'; | ||
| import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
| import { setupOtel } from '../../../../utils/setupOtel.js'; | ||
|
|
||
| const client = Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| release: '1.0', | ||
| tracesSampleRate: 1, | ||
| propagateTraceparent: true, | ||
| transport: loggingTransport, | ||
| }); | ||
|
|
||
| setupOtel(client); |
10 changes: 10 additions & 0 deletions
10
...ckages/node-core-integration-tests/suites/tracing/requests/traceparent/scenario-fetch.mjs
This file contains hidden or 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,10 @@ | ||
| import * as Sentry from '@sentry/node-core'; | ||
|
|
||
| async function run() { | ||
| // Wrap in span that is not sampled | ||
| await Sentry.startSpan({ name: 'outer' }, async () => { | ||
| await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text()); | ||
| }); | ||
| } | ||
|
|
||
| run(); |
21 changes: 21 additions & 0 deletions
21
...ackages/node-core-integration-tests/suites/tracing/requests/traceparent/scenario-http.mjs
This file contains hidden or 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 * as Sentry from '@sentry/node-core'; | ||
| import * as http from 'http'; | ||
|
|
||
| function makeHttpRequest(url) { | ||
| return new Promise(resolve => { | ||
| http | ||
| .request(url, httpRes => { | ||
| httpRes.on('data', () => { | ||
| // we don't care about data | ||
| }); | ||
| httpRes.on('end', () => { | ||
| resolve(); | ||
| }); | ||
| }) | ||
| .end(); | ||
| }); | ||
| } | ||
|
|
||
| await Sentry.startSpan({ name: 'outer' }, async () => { | ||
| await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`); | ||
| }); |
57 changes: 57 additions & 0 deletions
57
dev-packages/node-core-integration-tests/suites/tracing/requests/traceparent/test.ts
This file contains hidden or 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,57 @@ | ||
| import { describe, expect } from 'vitest'; | ||
| import { createEsmAndCjsTests } from '../../../../utils/runner'; | ||
| import { createTestServer } from '../../../../utils/server'; | ||
|
|
||
| describe('outgoing traceparent', () => { | ||
| createEsmAndCjsTests(__dirname, 'scenario-fetch.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('outgoing fetch requests should get traceparent headers', async () => { | ||
| expect.assertions(5); | ||
|
|
||
| const [SERVER_URL, closeTestServer] = await createTestServer() | ||
| .get('/api/v1', headers => { | ||
| expect(headers['baggage']).toEqual(expect.any(String)); | ||
| expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); | ||
| expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
| expect(headers['traceparent']).toEqual(expect.stringMatching(/^00-([a-f\d]{32})-([a-f\d]{16})-01$/)); | ||
| }) | ||
| .start(); | ||
|
|
||
| await createRunner() | ||
| .withEnv({ SERVER_URL }) | ||
| .expect({ | ||
| transaction: { | ||
| // we're not too concerned with the actual transaction here since this is tested elsewhere | ||
| }, | ||
| }) | ||
| .start() | ||
| .completed(); | ||
| closeTestServer(); | ||
| }); | ||
| }); | ||
|
|
||
| createEsmAndCjsTests(__dirname, 'scenario-http.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('outgoing http requests should get traceparent headers', async () => { | ||
| expect.assertions(5); | ||
|
|
||
| const [SERVER_URL, closeTestServer] = await createTestServer() | ||
| .get('/api/v1', headers => { | ||
| expect(headers['baggage']).toEqual(expect.any(String)); | ||
| expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); | ||
| expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
| expect(headers['traceparent']).toEqual(expect.stringMatching(/^00-([a-f\d]{32})-([a-f\d]{16})-01$/)); | ||
| }) | ||
| .start(); | ||
|
|
||
| await createRunner() | ||
| .withEnv({ SERVER_URL }) | ||
| .expect({ | ||
| transaction: { | ||
| // we're not too concerned with the actual transaction here since this is tested elsewhere | ||
| }, | ||
| }) | ||
| .start() | ||
| .completed(); | ||
| closeTestServer(); | ||
| }); | ||
| }); | ||
| }); |
10 changes: 10 additions & 0 deletions
10
dev-packages/node-integration-tests/suites/tracing/requests/traceparent/instrument.mjs
This file contains hidden or 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,10 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: 'https://[email protected]/1337', | ||
| release: '1.0', | ||
| tracesSampleRate: 1, | ||
| propagateTraceparent: true, | ||
| transport: loggingTransport, | ||
| }); |
10 changes: 10 additions & 0 deletions
10
dev-packages/node-integration-tests/suites/tracing/requests/traceparent/scenario-fetch.mjs
This file contains hidden or 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,10 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
|
|
||
| async function run() { | ||
| // Wrap in span that is not sampled | ||
| await Sentry.startSpan({ name: 'outer' }, async () => { | ||
| await fetch(`${process.env.SERVER_URL}/api/v1`).then(res => res.text()); | ||
| }); | ||
| } | ||
|
|
||
| run(); |
21 changes: 21 additions & 0 deletions
21
dev-packages/node-integration-tests/suites/tracing/requests/traceparent/scenario-http.mjs
This file contains hidden or 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 * as Sentry from '@sentry/node'; | ||
| import * as http from 'http'; | ||
|
|
||
| function makeHttpRequest(url) { | ||
| return new Promise(resolve => { | ||
| http | ||
| .request(url, httpRes => { | ||
| httpRes.on('data', () => { | ||
| // we don't care about data | ||
| }); | ||
| httpRes.on('end', () => { | ||
| resolve(); | ||
| }); | ||
| }) | ||
| .end(); | ||
| }); | ||
| } | ||
|
|
||
| Sentry.startSpan({ name: 'outer' }, async () => { | ||
| await makeHttpRequest(`${process.env.SERVER_URL}/api/v1`); | ||
| }); | ||
57 changes: 57 additions & 0 deletions
57
dev-packages/node-integration-tests/suites/tracing/requests/traceparent/test.ts
This file contains hidden or 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,57 @@ | ||
| import { describe, expect } from 'vitest'; | ||
| import { createEsmAndCjsTests } from '../../../../utils/runner'; | ||
| import { createTestServer } from '../../../../utils/server'; | ||
|
|
||
| describe('outgoing traceparent', () => { | ||
| createEsmAndCjsTests(__dirname, 'scenario-fetch.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('outgoing fetch requests should get traceparent headers', async () => { | ||
| expect.assertions(5); | ||
|
|
||
| const [SERVER_URL, closeTestServer] = await createTestServer() | ||
| .get('/api/v1', headers => { | ||
| expect(headers['baggage']).toEqual(expect.any(String)); | ||
| expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); | ||
| expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
| expect(headers['traceparent']).toEqual(expect.stringMatching(/^00-([a-f\d]{32})-([a-f\d]{16})-01$/)); | ||
| }) | ||
| .start(); | ||
|
|
||
| await createRunner() | ||
| .withEnv({ SERVER_URL }) | ||
| .expect({ | ||
| transaction: { | ||
| // we're not too concerned with the actual transaction here since this is tested elsewhere | ||
| }, | ||
| }) | ||
| .start() | ||
| .completed(); | ||
| closeTestServer(); | ||
| }); | ||
| }); | ||
|
|
||
| createEsmAndCjsTests(__dirname, 'scenario-http.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('outgoing http requests should get traceparent headers', async () => { | ||
| expect.assertions(5); | ||
|
|
||
| const [SERVER_URL, closeTestServer] = await createTestServer() | ||
| .get('/api/v1', headers => { | ||
| expect(headers['baggage']).toEqual(expect.any(String)); | ||
| expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); | ||
| expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); | ||
| expect(headers['traceparent']).toEqual(expect.stringMatching(/^00-([a-f\d]{32})-([a-f\d]{16})-01$/)); | ||
| }) | ||
| .start(); | ||
|
|
||
| await createRunner() | ||
| .withEnv({ SERVER_URL }) | ||
| .expect({ | ||
| transaction: { | ||
| // we're not too concerned with the actual transaction here since this is tested elsewhere | ||
| }, | ||
| }) | ||
| .start() | ||
| .completed(); | ||
| closeTestServer(); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.