Skip to content

Commit 40ea319

Browse files
committed
ref: Re-organize span-start hook
1 parent a1ef4a2 commit 40ea319

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

packages/node/src/integrations/tracing/tedious.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, spanToJSON } from
33
import type { IntegrationFn } from '@sentry/types';
44
import { generateInstrumentOnce } from '../../otel/instrument';
55

6+
const TEDIUS_INSTRUMENTED_METHODS = new Set([
7+
'callProcedure',
8+
'execSql',
9+
'execSqlBatch',
10+
'execBulkLoad',
11+
'prepare',
12+
'execute',
13+
]);
14+
615
const INTEGRATION_NAME = 'Tedious';
716

817
export const instrumentTedious = generateInstrumentOnce(INTEGRATION_NAME, () => new TediousInstrumentation({}));
@@ -16,13 +25,14 @@ const _tediousIntegration = (() => {
1625

1726
setup(client) {
1827
client.on('spanStart', span => {
19-
const spanJSON = spanToJSON(span);
20-
21-
const spanMethods = ['callProcedure', 'execSql', 'execSqlBatch', 'execBulkLoad', 'prepare', 'execute'];
22-
23-
const spanDescription = spanJSON?.description;
28+
const { description, data } = spanToJSON(span);
29+
// Tedius integration always set a span name and `db.system` attribute to `mssql`.
30+
if (!description || data?.['db.system'] !== 'mssql') {
31+
return;
32+
}
2433

25-
if (spanMethods.some(method => spanDescription?.startsWith(method))) {
34+
const operation = description?.split(' ')[0] || '';
35+
if (TEDIUS_INSTRUMENTED_METHODS.has(operation)) {
2636
span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.tedious');
2737
}
2838
});

0 commit comments

Comments
 (0)