-
-
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
12
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
12 commits
Select commit
Hold shift + click to select a range
b68be05
maybe this
chargome aa1da62
spankind detection
chargome ecc6928
backfill all ops
chargome 61e59b5
backfill source
chargome 9ebbc18
simplify
chargome 1466c92
fix
chargome a7d229b
order
chargome 39db71a
.
chargome 36a40cf
custom span name
chargome b1d574e
.
chargome 5615968
unit tests
chargome f0d206c
set url source
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.
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.