-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): Backfill otel attributes on streamed spans #20439
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
chargome
wants to merge
10
commits into
develop
Choose a base branch
from
cg/streamed-span-op-attribute
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.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a8b6c13
maybe this
chargome f23e7d1
spankind detection
chargome 49564b3
backfill all ops
chargome f994eb1
backfill source
chargome d602203
simplify
chargome 623ad14
fix
chargome 373ee88
Merge branch 'develop' into cg/streamed-span-op-attribute
chargome ccc0c2c
order
chargome c2e1043
.
chargome f630696
custom span name
chargome 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
.../node-integration-tests/suites/tracing/http-client-spans/fetch-basic-streamed/scenario.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,20 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { loggingTransport } from '@sentry-internal/node-integration-tests'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| release: '1.0', | ||
| tracesSampleRate: 1.0, | ||
| traceLifecycle: 'stream', | ||
| transport: loggingTransport, | ||
| }); | ||
|
|
||
| async function run(): Promise<void> { | ||
| await Sentry.startSpan({ name: 'test_transaction' }, async () => { | ||
| await fetch(`${process.env.SERVER_URL}/api/v0`); | ||
| }); | ||
|
|
||
| await Sentry.flush(); | ||
| } | ||
|
|
||
| void run(); |
29 changes: 29 additions & 0 deletions
29
...ages/node-integration-tests/suites/tracing/http-client-spans/fetch-basic-streamed/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,29 @@ | ||
| import { createTestServer } from '@sentry-internal/test-utils'; | ||
| import { expect, test } from 'vitest'; | ||
| import { createRunner } from '../../../../utils/runner'; | ||
|
|
||
| test('infers sentry.op for streamed outgoing fetch spans', async () => { | ||
| expect.assertions(2); | ||
|
|
||
| const [SERVER_URL, closeTestServer] = await createTestServer() | ||
| .get('/api/v0', () => { | ||
| expect(true).toBe(true); | ||
| }) | ||
| .start(); | ||
|
|
||
| await createRunner(__dirname, 'scenario.ts') | ||
| .withEnv({ SERVER_URL }) | ||
| .expect({ | ||
| span: container => { | ||
| const httpClientSpan = container.items.find( | ||
| item => | ||
| item.attributes?.['sentry.op']?.type === 'string' && item.attributes['sentry.op'].value === 'http.client', | ||
| ); | ||
|
|
||
| expect(httpClientSpan).toBeDefined(); | ||
| }, | ||
| }) | ||
| .start() | ||
| .completed(); | ||
| closeTestServer(); | ||
| }); |
10 changes: 10 additions & 0 deletions
10
dev-packages/node-integration-tests/suites/tracing/httpIntegration-streamed/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://public@dsn.ingest.sentry.io/1337', | ||
| release: '1.0', | ||
| tracesSampleRate: 1.0, | ||
| transport: loggingTransport, | ||
| traceLifecycle: 'stream', | ||
| }); |
16 changes: 16 additions & 0 deletions
16
dev-packages/node-integration-tests/suites/tracing/httpIntegration-streamed/server.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,16 @@ | ||
| import * as Sentry from '@sentry/node'; | ||
| import { startExpressServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests'; | ||
| import cors from 'cors'; | ||
| import express from 'express'; | ||
|
|
||
| const app = express(); | ||
|
|
||
| app.use(cors()); | ||
|
|
||
| app.get('/test', (_req, res) => { | ||
| res.send({ response: 'ok' }); | ||
| }); | ||
|
|
||
| Sentry.setupExpressErrorHandler(app); | ||
|
|
||
| startExpressServerAndSendPortToRunner(app); |
34 changes: 34 additions & 0 deletions
34
dev-packages/node-integration-tests/suites/tracing/httpIntegration-streamed/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,34 @@ | ||
| import { afterAll, describe, expect } from 'vitest'; | ||
| import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner'; | ||
|
|
||
| describe('httpIntegration-streamed', () => { | ||
| afterAll(() => { | ||
| cleanupChildProcesses(); | ||
| }); | ||
|
|
||
| createEsmAndCjsTests(__dirname, 'server.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('infers sentry.op, name, and source for streamed server spans', async () => { | ||
| const runner = createRunner() | ||
| .expect({ | ||
| span: container => { | ||
| const serverSpan = container.items.find( | ||
| item => | ||
| item.attributes?.['sentry.op']?.type === 'string' && | ||
| item.attributes['sentry.op'].value === 'http.server', | ||
| ); | ||
|
|
||
| expect(serverSpan).toBeDefined(); | ||
| expect(serverSpan?.is_segment).toBe(true); | ||
| expect(serverSpan?.name).toBe('GET /test'); | ||
| expect(serverSpan?.attributes?.['sentry.source']).toEqual({ type: 'string', value: 'route' }); | ||
| expect(serverSpan?.attributes?.['sentry.span.source']).toEqual({ type: 'string', value: 'route' }); | ||
| }, | ||
| }) | ||
| .start(); | ||
|
|
||
| await runner.makeRequest('get', '/test'); | ||
|
|
||
| await runner.completed(); | ||
| }); | ||
| }); | ||
| }); |
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.