Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { SerializedStreamedSpan } from '@sentry/core';
import {
DB_NAMESPACE,
DB_QUERY_SUMMARY,
Expand Down Expand Up @@ -123,44 +122,6 @@ describeWithDockerCompose('tedious auto instrumentation', { workingDirectory: [_
});
});

createEsmAndCjsTests(__dirname, 'scenario-no-parent.mjs', 'instrument.mjs', (createTestRunner, test) => {
Comment thread
nicohrubec marked this conversation as resolved.
Resolved
test('only instruments queries with an active parent span', async () => {
const runner = createTestRunner();
const dbSpans = new Map<string, SerializedStreamedSpan>();
const spansPromise = runner.collectStreamedSpans(spans => {
for (const span of spans) {
if (span.attributes[SENTRY_ORIGIN]?.value === ORIGIN) {
dbSpans.set(span.span_id, span);
}
}
return spans.some(span => span.is_segment && span.name === 'parent operation');
});

await runner.unordered().start().completed();

const spans = await spansPromise;
const parent = spans.find(span => span.is_segment && span.name === 'parent operation');
expect(parent).toBeDefined();
expect(
Array.from(dbSpans.values(), span => ({
query: span.attributes[DB_QUERY_TEXT]?.value,
database: span.attributes[DB_NAMESPACE]?.value,
parentSpanId: span.parent_span_id,
traceId: span.trace_id,
isSegment: span.is_segment,
})),
).toEqual([
{
query: 'SELECT ? AS inside_parent',
database: 'master',
parentSpanId: parent?.span_id,
traceId: parent?.trace_id,
isSegment: false,
},
]);
});
});

// tedious 20 requires Node >= 22.
describe.runIf(supports({ min: 22 }))('tedious v20', () => {
createEsmAndCjsTests(
Expand Down
6 changes: 1 addition & 5 deletions packages/server-utils/src/integrations/tedious.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as diagnosticsChannel from '../utils/diagnosticsChannel';
import type { IntegrationFn, SpanAttributes } from '@sentry/core';
import {
defineIntegration,
getActiveSpan,
getClient,
hasSpanStreamingEnabled,
SPAN_STATUS_ERROR,
Expand Down Expand Up @@ -111,10 +110,6 @@ function subscribeConnect(): void {

function subscribeQuery(channelName: string, operation: string): void {
diagnosticsChannel.tracingChannel(channelName).start.subscribe(message => {
if (!getActiveSpan()) {
return;
}

const data = message as TediousQueryChannelContext;
const connection = data.self;
const request = data.arguments[0];
Expand Down Expand Up @@ -162,6 +157,7 @@ function subscribeQuery(channelName: string, operation: string): void {
? querySummary || getLowCardinalitySecondarySpanName(operation, databaseName, sql, request.table)
: queryText || getSecondarySpanName(operation, databaseName, request.table),
attributes,
onlyIfParent: true,
Comment thread
nicohrubec marked this conversation as resolved.
Resolved
});

const endSpan = once((err?: { message?: string }): void => {
Expand Down
Loading