-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): Support attribute matching in ignoreSpans
#20512
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bbd8a82
implement
nicohrubec bc19a66
Merge branch 'develop' into nh/attributes-ignore-spans
nicohrubec 1fff7a3
add integration tests
nicohrubec 5eb68a2
chore: Bump size limits
nicohrubec 2d59315
add node integration test
nicohrubec aad1cb6
Merge remote-tracking branch 'origin/develop' into nh/attributes-igno…
nicohrubec f6beb42
.
nicohrubec 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
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
11 changes: 11 additions & 0 deletions
11
...packages/browser-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/init.js
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,11 @@ | ||
| import * as Sentry from '@sentry/browser'; | ||
|
|
||
| window.Sentry = Sentry; | ||
|
|
||
| Sentry.init({ | ||
| dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
| integrations: [Sentry.spanStreamingIntegration()], | ||
| ignoreSpans: [{ attributes: { 'http.status_code': 200 } }], | ||
| tracesSampleRate: 1, | ||
| debug: true, | ||
| }); |
11 changes: 11 additions & 0 deletions
11
...kages/browser-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/subject.js
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,11 @@ | ||
| // This segment span matches ignoreSpans via attributes — segment + child should be dropped | ||
| Sentry.startSpan({ name: 'health-check', attributes: { 'http.status_code': 200 } }, () => { | ||
| Sentry.startSpan({ name: 'child-of-ignored' }, () => {}); | ||
| }); | ||
|
|
||
| setTimeout(() => { | ||
| // This segment span does NOT match — segment + child should be sent | ||
| Sentry.startSpan({ name: 'normal-segment', attributes: { 'http.status_code': 500 } }, () => { | ||
| Sentry.startSpan({ name: 'child-span' }, () => {}); | ||
| }); | ||
| }, 1000); |
35 changes: 35 additions & 0 deletions
35
...packages/browser-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/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,35 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import type { ClientReport } from '@sentry/core'; | ||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
| import { | ||
| envelopeRequestParser, | ||
| hidePage, | ||
| shouldSkipTracingTest, | ||
| waitForClientReportRequest, | ||
| } from '../../../../utils/helpers'; | ||
| import { observeStreamedSpan, waitForStreamedSpans } from '../../../../utils/spanUtils'; | ||
|
|
||
| sentryTest('attribute-matching ignoreSpans drops the trace', async ({ getLocalTestUrl, page }) => { | ||
| sentryTest.skip(shouldSkipTracingTest()); | ||
|
|
||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
|
||
| observeStreamedSpan(page, span => { | ||
| if (span.name === 'health-check' || span.name === 'child-of-ignored') { | ||
| throw new Error('Ignored span found'); | ||
| } | ||
| return false; | ||
| }); | ||
|
|
||
| const spansPromise = waitForStreamedSpans(page, spans => !!spans?.find(s => s.name === 'normal-segment')); | ||
| const clientReportPromise = waitForClientReportRequest(page); | ||
|
|
||
| await page.goto(url); | ||
|
|
||
| expect((await spansPromise)?.length).toBe(2); | ||
|
|
||
| await hidePage(page); | ||
|
|
||
| const clientReport = envelopeRequestParser<ClientReport>(await clientReportPromise); | ||
| expect(clientReport.discarded_events).toEqual([{ category: 'span', quantity: 2, reason: 'ignored' }]); | ||
| }); |
4 changes: 2 additions & 2 deletions
4
...packages/browser-integration-tests/suites/tracing/ignoreSpans-streamed/segment/subject.js
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
12 changes: 12 additions & 0 deletions
12
...ages/node-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/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,12 @@ | ||
| 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', | ||
| ignoreSpans: [{ attributes: { 'http.method': 'POST' } }], | ||
| clientReportFlushInterval: 1_000, | ||
| }); |
25 changes: 25 additions & 0 deletions
25
...packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/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,25 @@ | ||
| import express from 'express'; | ||
| import cors from 'cors'; | ||
| import * as Sentry from '@sentry/node'; | ||
| import { startExpressServerAndSendPortToRunner } from '@sentry-internal/node-integration-tests'; | ||
|
|
||
| const app = express(); | ||
|
|
||
| app.use(cors()); | ||
|
|
||
| app.get('/keep', (_req, res) => { | ||
| res.send({ status: 'kept' }); | ||
| setTimeout(() => { | ||
| // flush to avoid waiting for the span buffer timeout to send spans | ||
| // but defer it to the next tick to let the SDK finish the http.server span first. | ||
| Sentry.flush(); | ||
| }); | ||
| }); | ||
|
|
||
| app.post('/drop', (_req, res) => { | ||
| res.send({ status: 'dropped' }); | ||
| }); | ||
|
|
||
| Sentry.setupExpressErrorHandler(app); | ||
|
|
||
| startExpressServerAndSendPortToRunner(app); |
44 changes: 44 additions & 0 deletions
44
dev-packages/node-integration-tests/suites/tracing/ignoreSpans-streamed/attributes/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,44 @@ | ||
| import { afterAll, describe, expect } from 'vitest'; | ||
| import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../../utils/runner'; | ||
|
|
||
| describe('filtering segment spans by attribute with ignoreSpans (streaming)', () => { | ||
| afterAll(() => { | ||
| cleanupChildProcesses(); | ||
| }); | ||
|
|
||
| createEsmAndCjsTests(__dirname, 'server.mjs', 'instrument.mjs', (createRunner, test) => { | ||
| test('segment spans matching an attribute filter are dropped including all children', async () => { | ||
| const runner = createRunner() | ||
| .unignore('client_report') | ||
| .expect({ | ||
| client_report: { | ||
| discarded_events: [ | ||
| { | ||
| category: 'span', | ||
| quantity: 5, // 1 segment ignored + 4 child spans (implicitly ignored) | ||
| reason: 'ignored', | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| .expect({ | ||
| span: container => { | ||
| expect(container.items).toHaveLength(5); | ||
| const segmentSpan = container.items.find(s => s.name === 'GET /keep' && !!s.is_segment); | ||
|
|
||
| expect(segmentSpan).toBeDefined(); | ||
| expect(container.items.every(s => s.trace_id === segmentSpan!.trace_id)).toBe(true); | ||
| }, | ||
| }) | ||
| .start(); | ||
|
|
||
| const dropRes = await runner.makeRequest('post', '/drop'); | ||
| expect((dropRes as { status: string }).status).toBe('dropped'); | ||
|
|
||
| const keepRes = await runner.makeRequest('get', '/keep'); | ||
| expect((keepRes as { status: string }).status).toBe('kept'); | ||
|
|
||
| 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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundle size increased across browser packages
Low Severity
Multiple browser bundle size limits were raised by ~1 KB gzipped (e.g.,
@sentry/browser26→27 KB, tracing 44→45 KB,@sentry/svelte26→27 KB, plus several CDN bundles). Per project rules, large bundle size increases in browser packages need to be flagged even when they may be unavoidable for a new feature.Additional Locations (2)
.size-limit.js#L42-L43.size-limit.js#L199-L200Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit aad1cb6. Configure here.