Skip to content

Commit ab1bc56

Browse files
nicohrubeccodex
andauthored
fix(server-utils): Use onlyIfParent for Tedious spans (#25876)
**Why:** Consolidating to use the core `onlyIfParent` logic everywhere so we can get rid of `requiresParentSpan`. --------- Co-authored-by: GPT-6 <codex@openai.com>
1 parent 1e3ef41 commit ab1bc56

3 files changed

Lines changed: 1 addition & 95 deletions

File tree

‎dev-packages/node-integration-tests/suites/tracing/tedious/scenario-no-parent.mjs‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎dev-packages/node-integration-tests/suites/tracing/tedious/test.ts‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { SerializedStreamedSpan } from '@sentry/core';
21
import {
32
DB_NAMESPACE,
43
DB_QUERY_SUMMARY,
@@ -123,44 +122,6 @@ describeWithDockerCompose('tedious auto instrumentation', { workingDirectory: [_
123122
});
124123
});
125124

126-
createEsmAndCjsTests(__dirname, 'scenario-no-parent.mjs', 'instrument.mjs', (createTestRunner, test) => {
127-
test('only instruments queries with an active parent span', async () => {
128-
const runner = createTestRunner();
129-
const dbSpans = new Map<string, SerializedStreamedSpan>();
130-
const spansPromise = runner.collectStreamedSpans(spans => {
131-
for (const span of spans) {
132-
if (span.attributes[SENTRY_ORIGIN]?.value === ORIGIN) {
133-
dbSpans.set(span.span_id, span);
134-
}
135-
}
136-
return spans.some(span => span.is_segment && span.name === 'parent operation');
137-
});
138-
139-
await runner.unordered().start().completed();
140-
141-
const spans = await spansPromise;
142-
const parent = spans.find(span => span.is_segment && span.name === 'parent operation');
143-
expect(parent).toBeDefined();
144-
expect(
145-
Array.from(dbSpans.values(), span => ({
146-
query: span.attributes[DB_QUERY_TEXT]?.value,
147-
database: span.attributes[DB_NAMESPACE]?.value,
148-
parentSpanId: span.parent_span_id,
149-
traceId: span.trace_id,
150-
isSegment: span.is_segment,
151-
})),
152-
).toEqual([
153-
{
154-
query: 'SELECT ? AS inside_parent',
155-
database: 'master',
156-
parentSpanId: parent?.span_id,
157-
traceId: parent?.trace_id,
158-
isSegment: false,
159-
},
160-
]);
161-
});
162-
});
163-
164125
// tedious 20 requires Node >= 22.
165126
describe.runIf(supports({ min: 22 }))('tedious v20', () => {
166127
createEsmAndCjsTests(

‎packages/server-utils/src/integrations/tedious.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as diagnosticsChannel from '../utils/diagnosticsChannel';
77
import type { IntegrationFn, SpanAttributes } from '@sentry/core';
88
import {
99
defineIntegration,
10-
getActiveSpan,
1110
getClient,
1211
hasSpanStreamingEnabled,
1312
SPAN_STATUS_ERROR,
@@ -111,10 +110,6 @@ function subscribeConnect(): void {
111110

112111
function subscribeQuery(channelName: string, operation: string): void {
113112
diagnosticsChannel.tracingChannel(channelName).start.subscribe(message => {
114-
if (!getActiveSpan()) {
115-
return;
116-
}
117-
118113
const data = message as TediousQueryChannelContext;
119114
const connection = data.self;
120115
const request = data.arguments[0];
@@ -162,6 +157,7 @@ function subscribeQuery(channelName: string, operation: string): void {
162157
? querySummary || getLowCardinalitySecondarySpanName(operation, databaseName, sql, request.table)
163158
: queryText || getSecondarySpanName(operation, databaseName, request.table),
164159
attributes,
160+
onlyIfParent: true,
165161
});
166162

167163
const endSpan = once((err?: { message?: string }): void => {

0 commit comments

Comments
 (0)