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
5 changes: 3 additions & 2 deletions packages/nuxt/src/runtime/utils/instrumentDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
startSpan,
type StartSpanOptions,
} from '@sentry/core';
import { _INTERNAL_getSqlQuerySummary, _INTERNAL_sanitizeSqlQuery, flushIfServerless } from '@sentry/core/server';
import { flushIfServerless } from '@sentry/core/server';
import { getSqlQuerySummary, sanitizeSqlQuery } from '@sentry/server-utils';
import type { Database, PreparedStatement } from 'db0';
import { type DatabaseConnectionConfig, type DatabaseSpanData, getDatabaseSpanData } from './database-span-data';
import { DB_NAMESPACE, DB_QUERY_SUMMARY, DB_QUERY_TEXT, DB_SYSTEM_NAME } from '@sentry/conventions/attributes';
Expand Down Expand Up @@ -249,7 +250,7 @@ function createBreadcrumb(query: string): void {
* Creates a start span options object.
*/
function createStartSpanOptions(query: string, data: DatabaseSpanData): StartSpanOptions {
const querySummary = query ? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(query)) : undefined;
const querySummary = query ? getSqlQuerySummary(sanitizeSqlQuery(query)) : undefined;

const client = getClient();
const name =
Expand Down
6 changes: 2 additions & 4 deletions packages/server-utils/src/integrations/knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { DB } from '@sentry/conventions/op';
import { DEBUG_BUILD } from '../debug-build';
import { CHANNELS } from '../orchestrion/channels';
import { bindTracingChannelToSpan } from '../tracing-channel';
import { _INTERNAL_getSqlQuerySummary, _INTERNAL_sanitizeSqlQuery } from '@sentry/core/server';
import { getSqlQuerySummary, sanitizeSqlQuery } from '../utils/sql';

// NOTE: this uses the same name as the OTel integration by design. `@sentry/node`'s `knexIntegration`
// picks this subscriber over the vendored OTel path when orchestrion injection is active.
Expand Down Expand Up @@ -176,9 +176,7 @@ function subscribeQuery(): void {

const dbStatement = query?.sql != null ? truncate(query.sql, MAX_QUERY_LENGTH) : undefined;
const dialect = client?.driverName === 'mysql' || client?.driverName === 'mysql2' ? 'mysql' : undefined;
const querySummary = dbStatement
? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(dbStatement, dialect))
: undefined;
const querySummary = dbStatement ? getSqlQuerySummary(sanitizeSqlQuery(dbStatement, dialect)) : undefined;
const attributes: SpanAttributes = {
[SENTRY_OP]: DB,
[SENTRY_KIND]: 'client',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
SENTRY_KIND,
SENTRY_OP,
} from '@sentry/conventions/attributes';
import { _INTERNAL_getSqlQuerySummary, _INTERNAL_sanitizeSqlQuery } from '@sentry/core/server';
import { getSqlQuerySummary, sanitizeSqlQuery } from '../../utils/sql';

// Reading `process.env` can throw in runtimes that gate env access (e.g. Deno without `--allow-env`)
// and `process` may be absent altogether (edge runtimes), so this degrades to `false` in those cases.
Expand Down Expand Up @@ -117,7 +117,7 @@ function buildSpanAttributes(name: string, attributes: Record<string, unknown> |
if (statement) {
// Sanitized before summarizing, so that a string literal containing `from`/`join` can't leak a
// value into the summary.
merged[DB_QUERY_SUMMARY] = _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(statement));
merged[DB_QUERY_SUMMARY] = getSqlQuerySummary(sanitizeSqlQuery(statement));
}

return merged;
Expand Down
5 changes: 2 additions & 3 deletions packages/server-utils/src/integrations/tedious.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { DB } from '@sentry/conventions/op';
import { CHANNELS } from '../orchestrion/channels';
import { tediousModuleNames } from '../orchestrion/config/tedious';
import { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';
import { _INTERNAL_getSqlQuerySummary, _INTERNAL_sanitizeSqlQuery } from '@sentry/core/server';
import { getSqlQuerySummary, sanitizeSqlQuery } from '../utils/sql';

// NOTE: this uses the same name as the OTel integration by design. When orchestrion injection is active,
// `_init` swaps the OTel `Tedious` integration out of the defaults and appends this one (matched by name).
Expand Down Expand Up @@ -132,8 +132,7 @@ function subscribeQuery(channelName: string, operation: string): void {

const databaseName = connection[currentDatabaseSymbol];
const sql = extractSql(request);
const querySummary =
sql && operation !== 'callProcedure' ? _INTERNAL_getSqlQuerySummary(_INTERNAL_sanitizeSqlQuery(sql)) : undefined;
const querySummary = sql && operation !== 'callProcedure' ? getSqlQuerySummary(sanitizeSqlQuery(sql)) : undefined;

const attributes: SpanAttributes = {
[SENTRY_OP]: DB,
Expand Down
Loading