Skip to content

Commit 428c3bf

Browse files
committed
apply review feedback
1 parent 6b5158a commit 428c3bf

2 files changed

Lines changed: 7 additions & 17 deletions

File tree

packages/server-utils/src/integrations/knex.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function subscribeBuilder(channelName: string): void {
153153
function subscribeQuery(): void {
154154
bindTracingChannelToSpan<KnexQueryChannelContext>(
155155
diagnosticsChannel.tracingChannel<KnexQueryChannelContext>(CHANNELS.KNEX_QUERY),
156+
// oxlint-disable-next-line complexity
156157
data => {
157158
const runner = data.self;
158159
const builder = runner?.builder;
@@ -175,10 +176,9 @@ function subscribeQuery(): void {
175176
const dbSystem = mapSystem(client?.driverName);
176177

177178
const dbStatement = query?.sql != null ? truncate(query.sql, MAX_QUERY_LENGTH) : undefined;
178-
// The statement is sanitized before it is summarized, so that a string literal containing
179-
// `from`/`join` can't leak a value into the summary.
179+
const dialect = client?.driverName === 'mysql' || client?.driverName === 'mysql2' ? 'mysql' : undefined;
180180
const querySummary = dbStatement
181-
? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(dbStatement))
181+
? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(dbStatement, dialect))
182182
: undefined;
183183
const attributes: SpanAttributes = {
184184
[SENTRY_OP]: DB,

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ function subscribeQuery(channelName: string, operation: string): void {
156156
const span = startInactiveSpan({
157157
name:
158158
client && hasSpanStreamingEnabled(client)
159-
? (querySummary ?? getLowCardinalitySecondarySpanName(operation, databaseName, sql, request.table))
160-
: sql || getSecondarySpanName(operation, databaseName, sql, request.table),
159+
? querySummary || getLowCardinalitySecondarySpanName(operation, databaseName, sql, request.table)
160+
: sql || getSecondarySpanName(operation, databaseName, request.table),
161161
attributes,
162162
});
163163

@@ -209,22 +209,12 @@ function extractSql(request: TediousRequest): string | undefined {
209209
}
210210

211211
/**
212-
* The span name is a low-cardinality label for the operation; the SDK's db-span inference later renames
213-
* the span description off `db.query.text` when present. Mirrors the vendored OTel `getSpanName`.
212+
* Get a secondary span name for static trace lifecycle (not strictly adhering to sentry-convention span names)
214213
*/
215-
function getSecondarySpanName(
216-
operation: string,
217-
db: string | undefined,
218-
sql: string | undefined,
219-
bulkLoadTable: string | undefined,
220-
): string {
214+
function getSecondarySpanName(operation: string, db: string | undefined, bulkLoadTable: string | undefined): string {
221215
if (operation === 'execBulkLoad' && bulkLoadTable && db) {
222216
return `${operation} ${bulkLoadTable} ${db}`;
223217
}
224-
if (operation === 'callProcedure' && sql) {
225-
// `sql` refers to the procedure name for `callProcedure`.
226-
return db ? `${operation} ${sql} ${db}` : `${operation} ${sql}`;
227-
}
228218
// Avoid `sql` in the general case because of its high cardinality.
229219
return db ? `${operation} ${db}` : operation;
230220
}

0 commit comments

Comments
 (0)