From 065f1ebcaec48112736e3051b37c2c3288207619 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 1 Jul 2026 16:39:13 +0200 Subject: [PATCH 1/2] ref(node): Use `@sentry/conventions` and vendor remaining semantic conventions Source span attribute keys in `@sentry/node` from `@sentry/conventions/attributes` instead of `@opentelemetry/semantic-conventions` and the locally vendored `./semconv` constants, for attributes that have a `@sentry/conventions` equivalent. Keys without an equivalent and all value constants stay vendored locally. The package source no longer imports `@opentelemetry/semantic-conventions`, and the dependency is removed. No functional change: all string values are identical. Co-Authored-By: Claude Opus 4.8 --- packages/node/package.json | 1 - .../tracing/amqplib/vendored/semconv.ts | 9 --- .../tracing/amqplib/vendored/utils.ts | 16 ++-- .../connect/vendored/instrumentation.ts | 4 +- .../tracing/fastify/v3/instrumentation.ts | 4 +- .../firebase/otel/patches/firestore.ts | 26 +++---- .../tracing/hapi/vendored/semconv.ts | 22 ------ .../tracing/hapi/vendored/utils.ts | 7 +- .../src/integrations/tracing/hono/index.ts | 6 +- .../tracing/kafka/vendored/instrumentation.ts | 4 +- .../tracing/kafka/vendored/semconv.ts | 74 ++----------------- .../tracing/kafka/vendored/utils.ts | 30 ++++---- .../tracing/knex/vendored/instrumentation.ts | 38 +++++----- .../tracing/knex/vendored/semconv.ts | 40 ---------- .../tracing/koa/vendored/instrumentation.ts | 4 +- .../tracing/koa/vendored/utils.ts | 4 +- .../tracing/mongo/vendored/semconv.ts | 44 +---------- .../tracing/mongo/vendored/utils.ts | 32 ++++---- .../tracing/mongoose/vendored/mongoose.ts | 10 +-- .../tracing/mongoose/vendored/semconv.ts | 54 -------------- .../tracing/mongoose/vendored/utils.ts | 24 ++---- .../tracing/mysql/vendored/instrumentation.ts | 31 ++++---- .../tracing/mysql/vendored/semconv.ts | 69 +---------------- .../mysql2/vendored/instrumentation.ts | 9 ++- .../tracing/mysql2/vendored/semconv.ts | 6 -- .../tracing/mysql2/vendored/utils.ts | 19 ++--- .../tracing/postgres/vendored/semconv.ts | 57 +------------- .../tracing/postgres/vendored/utils.ts | 39 +++++----- .../src/integrations/tracing/postgresjs.ts | 20 ++--- .../redis/vendored/ioredis-instrumentation.ts | 28 +++---- .../redis/vendored/redis-instrumentation.ts | 28 +++---- .../tracing/redis/vendored/semconv.ts | 4 - .../tedious/vendored/instrumentation.ts | 29 ++++---- .../tracing/tedious/vendored/semconv.ts | 69 +---------------- 34 files changed, 203 insertions(+), 658 deletions(-) delete mode 100644 packages/node/src/integrations/tracing/hapi/vendored/semconv.ts diff --git a/packages/node/package.json b/packages/node/package.json index e6b2c0f9b410..643d1042cf09 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -68,7 +68,6 @@ "@opentelemetry/api": "^1.9.1", "@opentelemetry/instrumentation": "^0.214.0", "@opentelemetry/sdk-trace-base": "^2.6.1", - "@opentelemetry/semantic-conventions": "^1.40.0", "@sentry/conventions": "^0.12.0", "@sentry/core": "10.63.0", "@sentry/node-core": "10.63.0", diff --git a/packages/node/src/integrations/tracing/amqplib/vendored/semconv.ts b/packages/node/src/integrations/tracing/amqplib/vendored/semconv.ts index 32248dfbf215..ffabc460056c 100644 --- a/packages/node/src/integrations/tracing/amqplib/vendored/semconv.ts +++ b/packages/node/src/integrations/tracing/amqplib/vendored/semconv.ts @@ -11,18 +11,9 @@ * copies are intentionally the chosen output and we don't want to flag every usage site. */ -/** The messaging system as identified by the client instrumentation, e.g. `rabbitmq`. */ -export const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const; - /** A string identifying the kind of message consumption. */ export const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const; -/** Host name of the message broker. */ -export const ATTR_NET_PEER_NAME = 'net.peer.name' as const; - -/** Port of the message broker. */ -export const ATTR_NET_PEER_PORT = 'net.peer.port' as const; - /** The message destination name (the exchange for amqplib). */ export const ATTR_MESSAGING_DESTINATION = 'messaging.destination' as const; diff --git a/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts b/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts index 6edf577d03d8..0378dee312d2 100644 --- a/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts +++ b/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts @@ -12,9 +12,12 @@ * - Replaced the OTel context-key confirm-channel marker with a synchronous flag on the channel instance */ +/* oxlint-disable typescript/no-deprecated */ + import { SpanKind } from '@opentelemetry/api'; import type { Span, SpanAttributes } from '@sentry/core'; import { getTraceData, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core'; +import { MESSAGING_SYSTEM, NET_PEER_NAME, NET_PEER_PORT } from '@sentry/conventions/attributes'; import type { Channel, ConfirmChannel, Connection, Options } from './amqplib-types'; import { ATTR_MESSAGING_CONVERSATION_ID, @@ -24,10 +27,7 @@ import { ATTR_MESSAGING_PROTOCOL, ATTR_MESSAGING_PROTOCOL_VERSION, ATTR_MESSAGING_RABBITMQ_ROUTING_KEY, - ATTR_MESSAGING_SYSTEM, ATTR_MESSAGING_URL, - ATTR_NET_PEER_NAME, - ATTR_NET_PEER_PORT, MESSAGING_DESTINATION_KIND_VALUE_TOPIC, MESSAGING_OPERATION_VALUE_PROCESS, OLD_ATTR_MESSAGING_MESSAGE_ID, @@ -99,7 +99,7 @@ export const getConnectionAttributesFromServer = (conn: Connection): SpanAttribu const product = conn.serverProperties.product?.toLowerCase?.(); if (product) { return { - [ATTR_MESSAGING_SYSTEM]: product, + [MESSAGING_SYSTEM]: product, }; } else { return {}; @@ -117,8 +117,8 @@ export const getConnectionAttributesFromUrl = (url: string | Options.Connect): S const protocol = getProtocol(connectOptions?.protocol); attributes[ATTR_MESSAGING_PROTOCOL] = protocol; - attributes[ATTR_NET_PEER_NAME] = getHostname(connectOptions?.hostname); - attributes[ATTR_NET_PEER_PORT] = getPort(connectOptions.port, protocol); + attributes[NET_PEER_NAME] = getHostname(connectOptions?.hostname); + attributes[NET_PEER_PORT] = getPort(connectOptions.port, protocol); } else { const censoredUrl = censorPassword(resolvedUrl); attributes[ATTR_MESSAGING_URL] = censoredUrl; @@ -127,8 +127,8 @@ export const getConnectionAttributesFromUrl = (url: string | Options.Connect): S const protocol = getProtocol(urlParts.protocol); attributes[ATTR_MESSAGING_PROTOCOL] = protocol; - attributes[ATTR_NET_PEER_NAME] = getHostname(urlParts.hostname); - attributes[ATTR_NET_PEER_PORT] = getPort(urlParts.port ? parseInt(urlParts.port) : undefined, protocol); + attributes[NET_PEER_NAME] = getHostname(urlParts.hostname); + attributes[NET_PEER_PORT] = getPort(urlParts.port ? parseInt(urlParts.port) : undefined, protocol); } catch { // best-effort: a malformed url simply yields fewer connection attributes } diff --git a/packages/node/src/integrations/tracing/connect/vendored/instrumentation.ts b/packages/node/src/integrations/tracing/connect/vendored/instrumentation.ts index 6d1255a02708..8328c03ebac8 100644 --- a/packages/node/src/integrations/tracing/connect/vendored/instrumentation.ts +++ b/packages/node/src/integrations/tracing/connect/vendored/instrumentation.ts @@ -22,7 +22,7 @@ import { import { setHttpServerSpanRouteAttribute } from '../../../../utils/setHttpServerSpanRouteAttribute'; import type { InstrumentationConfig } from '@opentelemetry/instrumentation'; import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation'; -import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; +import { HTTP_ROUTE } from '@sentry/conventions/attributes'; import { replaceCurrentStackRoute, addNewStackLayer, generateRoute } from './utils'; const PACKAGE_NAME = '@sentry/instrumentation-connect'; @@ -82,7 +82,7 @@ export class ConnectInstrumentation extends InstrumentationBase { op: `${connectType}.connect`, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.connect', - [ATTR_HTTP_ROUTE]: routeName.length > 0 ? routeName : '/', + [HTTP_ROUTE]: routeName.length > 0 ? routeName : '/', [AttributeNames.CONNECT_TYPE]: connectType, [AttributeNames.CONNECT_NAME]: connectName, }, diff --git a/packages/node/src/integrations/tracing/fastify/v3/instrumentation.ts b/packages/node/src/integrations/tracing/fastify/v3/instrumentation.ts index e42ac1514341..d464b3d4d8cf 100644 --- a/packages/node/src/integrations/tracing/fastify/v3/instrumentation.ts +++ b/packages/node/src/integrations/tracing/fastify/v3/instrumentation.ts @@ -27,7 +27,7 @@ import { InstrumentationNodeModuleDefinition, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; -import { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; +import { HTTP_ROUTE } from '@sentry/conventions/attributes'; import type { Span } from '@sentry/core'; import { getClient, @@ -265,7 +265,7 @@ export class FastifyInstrumentationV3 extends InstrumentationBase( kind: SPAN_KIND.CLIENT, attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.firestore', - [ATTR_DB_OPERATION_NAME]: spanName, + [DB_OPERATION_NAME]: spanName, ...buildAttributes(reference), }, }, @@ -248,9 +248,9 @@ function buildAttributes( const settings: FirestoreSettings = json.settings || {}; const attributes: SpanAttributes = { - [ATTR_DB_COLLECTION_NAME]: reference.path, - [ATTR_DB_NAMESPACE]: firestoreApp.name, - [ATTR_DB_SYSTEM_NAME]: 'firebase.firestore', + [DB_COLLECTION_NAME]: reference.path, + [DB_NAMESPACE]: firestoreApp.name, + [DB_SYSTEM_NAME]: 'firebase.firestore', 'firebase.firestore.type': reference.type, 'firebase.firestore.options.projectId': firestoreOptions.projectId, 'firebase.firestore.options.appId': firestoreOptions.appId, @@ -261,10 +261,10 @@ function buildAttributes( const { address, port } = getPortAndAddress(settings); if (address) { - attributes[ATTR_SERVER_ADDRESS] = address; + attributes[SERVER_ADDRESS] = address; } if (port) { - attributes[ATTR_SERVER_PORT] = port; + attributes[SERVER_PORT] = port; } return attributes; diff --git a/packages/node/src/integrations/tracing/hapi/vendored/semconv.ts b/packages/node/src/integrations/tracing/hapi/vendored/semconv.ts deleted file mode 100644 index 47a95d66f4e8..000000000000 --- a/packages/node/src/integrations/tracing/hapi/vendored/semconv.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - * - * NOTICE from the Sentry authors: - * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-hapi - * - Upstream version: @opentelemetry/instrumentation-hapi@0.64.0 - */ -/* eslint-disable */ - -/** - * Deprecated, use `http.request.method` instead. - * - * @example GET - * @example POST - * @example HEAD - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `http.request.method`. - */ -export const ATTR_HTTP_METHOD = 'http.method' as const; diff --git a/packages/node/src/integrations/tracing/hapi/vendored/utils.ts b/packages/node/src/integrations/tracing/hapi/vendored/utils.ts index 1c68fb2690f9..0b35c8bac885 100644 --- a/packages/node/src/integrations/tracing/hapi/vendored/utils.ts +++ b/packages/node/src/integrations/tracing/hapi/vendored/utils.ts @@ -9,8 +9,7 @@ */ import type { Attributes } from '@opentelemetry/api'; -import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; -import { ATTR_HTTP_METHOD } from './semconv'; +import { HTTP_METHOD, HTTP_ROUTE } from '@sentry/conventions/attributes'; import type * as Hapi from './hapi-types'; import { HapiLayerType, @@ -63,9 +62,9 @@ export const getRouteMetadata = ( name: string; } => { const attributes: Attributes = { - [ATTR_HTTP_ROUTE]: route.path, + [HTTP_ROUTE]: route.path, // eslint-disable-next-line typescript/no-deprecated - [ATTR_HTTP_METHOD]: route.method, + [HTTP_METHOD]: route.method, }; let name; diff --git a/packages/node/src/integrations/tracing/hono/index.ts b/packages/node/src/integrations/tracing/hono/index.ts index 65039dd35a5c..3b97cd84bf06 100644 --- a/packages/node/src/integrations/tracing/hono/index.ts +++ b/packages/node/src/integrations/tracing/hono/index.ts @@ -1,4 +1,4 @@ -import { ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; +import { HTTP_REQUEST_METHOD, HTTP_ROUTE } from '@sentry/conventions/attributes'; import type { IntegrationFn, Span } from '@sentry/core'; import { captureException, @@ -41,8 +41,8 @@ function addHonoSpanAttributes(span: Span): void { return; } - const route = attributes[ATTR_HTTP_ROUTE]; - const method = attributes[ATTR_HTTP_REQUEST_METHOD]; + const route = attributes[HTTP_ROUTE]; + const method = attributes[HTTP_REQUEST_METHOD]; if (typeof route === 'string' && typeof method === 'string') { getIsolationScope().setTransactionName(`${method} ${route}`); } diff --git a/packages/node/src/integrations/tracing/kafka/vendored/instrumentation.ts b/packages/node/src/integrations/tracing/kafka/vendored/instrumentation.ts index 0aed0d232654..d9a5e65237ee 100644 --- a/packages/node/src/integrations/tracing/kafka/vendored/instrumentation.ts +++ b/packages/node/src/integrations/tracing/kafka/vendored/instrumentation.ts @@ -15,6 +15,7 @@ import type { InstrumentationConfig } from '@opentelemetry/instrumentation'; import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation'; +import { MESSAGING_BATCH_MESSAGE_COUNT } from '@sentry/conventions/attributes'; import type { Span } from '@sentry/core'; import { continueTrace, @@ -37,7 +38,6 @@ import type { Transaction, } from './kafkajs-types'; import { - ATTR_MESSAGING_BATCH_MESSAGE_COUNT, ATTR_MESSAGING_DESTINATION_PARTITION_ID, MESSAGING_OPERATION_TYPE_VALUE_PROCESS, MESSAGING_OPERATION_TYPE_VALUE_RECEIVE, @@ -191,7 +191,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase(spans: Span[], sendPromise: Promise): Pr } spans.forEach(span => { - span.setAttribute(ATTR_ERROR_TYPE, errorType); + span.setAttribute(ERROR_TYPE, errorType); span.setStatus({ code: SPAN_STATUS_ERROR, message: errorMessage, diff --git a/packages/node/src/integrations/tracing/knex/vendored/instrumentation.ts b/packages/node/src/integrations/tracing/knex/vendored/instrumentation.ts index 2acd863b7838..89ae16cd6c4d 100644 --- a/packages/node/src/integrations/tracing/knex/vendored/instrumentation.ts +++ b/packages/node/src/integrations/tracing/knex/vendored/instrumentation.ts @@ -22,18 +22,18 @@ import { SPAN_STATUS_ERROR, startSpan, } from '@sentry/core'; -import { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile'; import { - ATTR_DB_NAME, - ATTR_DB_OPERATION, - ATTR_DB_SQL_TABLE, - ATTR_DB_STATEMENT, - ATTR_DB_SYSTEM, - ATTR_DB_USER, - ATTR_NET_PEER_NAME, - ATTR_NET_PEER_PORT, - ATTR_NET_TRANSPORT, -} from './semconv'; + DB_NAME, + DB_OPERATION, + DB_STATEMENT, + DB_SYSTEM, + DB_USER, + NET_PEER_NAME, + NET_PEER_PORT, + NET_TRANSPORT, +} from '@sentry/conventions/attributes'; +import { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile'; +import { ATTR_DB_SQL_TABLE } from './semconv'; import * as utils from './utils'; const PACKAGE_NAME = '@sentry/instrumentation-knex'; @@ -124,15 +124,15 @@ export class KnexInstrumentation extends InstrumentationBase { - const route = metadata.attributes[ATTR_HTTP_ROUTE]; + const route = metadata.attributes[HTTP_ROUTE]; if (getIsolationScope() === getDefaultIsolationScope()) { DEBUG_BUILD && debug.warn('Isolation scope is default isolation scope - skipping setting transactionName'); } else if (route) { diff --git a/packages/node/src/integrations/tracing/koa/vendored/utils.ts b/packages/node/src/integrations/tracing/koa/vendored/utils.ts index f052b1385d9a..1c9d9a8067a9 100644 --- a/packages/node/src/integrations/tracing/koa/vendored/utils.ts +++ b/packages/node/src/integrations/tracing/koa/vendored/utils.ts @@ -11,7 +11,7 @@ import { KoaLayerType, type KoaInstrumentationConfig } from './types'; import type { KoaContext, KoaMiddleware } from './internal-types'; import { AttributeNames } from './enums/AttributeNames'; import type { Attributes } from '@opentelemetry/api'; -import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions'; +import { HTTP_ROUTE } from '@sentry/conventions/attributes'; export const getMiddlewareMetadata = ( context: KoaContext, @@ -27,7 +27,7 @@ export const getMiddlewareMetadata = ( attributes: { [AttributeNames.KOA_NAME]: layerPath?.toString(), [AttributeNames.KOA_TYPE]: KoaLayerType.ROUTER, - [ATTR_HTTP_ROUTE]: layerPath?.toString(), + [HTTP_ROUTE]: layerPath?.toString(), }, name: context._matchedRouteName || `router - ${layerPath}`, }; diff --git a/packages/node/src/integrations/tracing/mongo/vendored/semconv.ts b/packages/node/src/integrations/tracing/mongo/vendored/semconv.ts index b892caade680..1a4c1680e84f 100644 --- a/packages/node/src/integrations/tracing/mongo/vendored/semconv.ts +++ b/packages/node/src/integrations/tracing/mongo/vendored/semconv.ts @@ -28,48 +28,6 @@ export const ATTR_DB_CONNECTION_STRING = 'db.connection_string' as const; export const ATTR_DB_MONGODB_COLLECTION = 'db.mongodb.collection' as const; /** - * Deprecated, use `db.namespace` instead. - * - * @deprecated Replaced by `db.namespace`. - */ -export const ATTR_DB_NAME = 'db.name' as const; - -/** - * Deprecated, use `db.operation.name` instead. - * - * @deprecated Replaced by `db.operation.name`. - */ -export const ATTR_DB_OPERATION = 'db.operation' as const; - -/** - * The database statement being executed. - * - * @deprecated Replaced by `db.query.text`. - */ -export const ATTR_DB_STATEMENT = 'db.statement' as const; - -/** - * Deprecated, use `db.system.name` instead. - * - * @deprecated Replaced by `db.system.name`. - */ -export const ATTR_DB_SYSTEM = 'db.system' as const; - -/** - * Deprecated, use `server.address` on client spans and `client.address` on server spans. - * - * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans. - */ -export const ATTR_NET_PEER_NAME = 'net.peer.name' as const; - -/** - * Deprecated, use `server.port` on client spans and `client.port` on server spans. - * - * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans. - */ -export const ATTR_NET_PEER_PORT = 'net.peer.port' as const; - -/** - * Enum value "mongodb" for attribute {@link ATTR_DB_SYSTEM}. + * Enum value "mongodb" for attribute `db.system`. */ export const DB_SYSTEM_VALUE_MONGODB = 'mongodb' as const; diff --git a/packages/node/src/integrations/tracing/mongo/vendored/utils.ts b/packages/node/src/integrations/tracing/mongo/vendored/utils.ts index 45c80f2617dc..435b45f50030 100644 --- a/packages/node/src/integrations/tracing/mongo/vendored/utils.ts +++ b/packages/node/src/integrations/tracing/mongo/vendored/utils.ts @@ -18,16 +18,14 @@ import { withActiveSpan, } from '@sentry/core'; import { - ATTR_DB_CONNECTION_STRING, - ATTR_DB_MONGODB_COLLECTION, - ATTR_DB_NAME, - ATTR_DB_OPERATION, - ATTR_DB_STATEMENT, - ATTR_DB_SYSTEM, - ATTR_NET_PEER_NAME, - ATTR_NET_PEER_PORT, - DB_SYSTEM_VALUE_MONGODB, -} from './semconv'; + DB_NAME, + DB_OPERATION, + DB_STATEMENT, + DB_SYSTEM, + NET_PEER_NAME, + NET_PEER_PORT, +} from '@sentry/conventions/attributes'; +import { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv'; import type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types'; import { MongodbCommandType } from './internal-types'; @@ -166,31 +164,31 @@ function getSpanAttributes( const attributes: SpanAttributes = { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN, // eslint-disable-next-line typescript/no-deprecated - [ATTR_DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB, + [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB, // eslint-disable-next-line typescript/no-deprecated - [ATTR_DB_NAME]: dbName, + [DB_NAME]: dbName, // eslint-disable-next-line typescript/no-deprecated [ATTR_DB_MONGODB_COLLECTION]: dbCollection, // eslint-disable-next-line typescript/no-deprecated - [ATTR_DB_OPERATION]: operation, + [DB_OPERATION]: operation, // eslint-disable-next-line typescript/no-deprecated [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`, }; if (host && port) { // eslint-disable-next-line typescript/no-deprecated - attributes[ATTR_NET_PEER_NAME] = host; + attributes[NET_PEER_NAME] = host; const portNumber = parseInt(port, 10); if (!isNaN(portNumber)) { // eslint-disable-next-line typescript/no-deprecated - attributes[ATTR_NET_PEER_PORT] = portNumber; + attributes[NET_PEER_PORT] = portNumber; } } if (commandObj) { try { // eslint-disable-next-line typescript/no-deprecated - attributes[ATTR_DB_STATEMENT] = serializeDbStatement(commandObj); + attributes[DB_STATEMENT] = serializeDbStatement(commandObj); } catch { // ignore serialization errors — the statement is best-effort metadata } @@ -202,7 +200,7 @@ function getSpanAttributes( export function startMongoSpan(attributes: SpanAttributes): Span { return startInactiveSpan({ // eslint-disable-next-line typescript/no-deprecated - name: `mongodb.${attributes[ATTR_DB_OPERATION] || 'command'}`, + name: `mongodb.${attributes[DB_OPERATION] || 'command'}`, kind: SPAN_KIND.CLIENT, attributes, }); diff --git a/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts b/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts index cb4de45e9978..956b64923ba5 100644 --- a/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts +++ b/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts @@ -10,12 +10,15 @@ * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs */ +/* oxlint-disable typescript/no-deprecated */ + import { type InstrumentationConfig, InstrumentationBase, type InstrumentationModuleDefinition, InstrumentationNodeModuleDefinition, } from '@opentelemetry/instrumentation'; +import { DB_OPERATION, DB_SYSTEM } from '@sentry/conventions/attributes'; import type { Span, SpanAttributes } from '@sentry/core'; import { getActiveSpan, @@ -26,7 +29,6 @@ import { withActiveSpan, } from '@sentry/core'; import type * as mongoose from './mongoose-types'; -import { ATTR_DB_OPERATION, ATTR_DB_SYSTEM } from './semconv'; import { getAttributesFromCollection, handleCallbackResponse, handlePromiseResponse } from './utils'; const PACKAGE_NAME = '@sentry/instrumentation-mongoose'; @@ -297,10 +299,8 @@ export class MongooseInstrumentation extends InstrumentationBase=3.0.0 <4']; +// Not part of `@sentry/conventions`, so we keep it inline. +const ATTR_DB_RESPONSE_STATUS_CODE = 'db.response.status_code'; const SQL_OPERATION_REGEX = /^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i; type PostgresConnectionContext = { @@ -187,13 +183,13 @@ export class PostgresJsInstrumentation extends InstrumentationBase=4 uses `authentication` object; older versions just userName and password pair // eslint-disable-next-line typescript/no-deprecated - [ATTR_DB_USER]: this.config?.userName ?? this.config?.authentication?.options?.userName, + [DB_USER]: this.config?.userName ?? this.config?.authentication?.options?.userName, // eslint-disable-next-line typescript/no-deprecated - [ATTR_DB_STATEMENT]: sql, + [DB_STATEMENT]: sql, // eslint-disable-next-line typescript/no-deprecated [ATTR_DB_SQL_TABLE]: request.table, // eslint-disable-next-line typescript/no-deprecated - [ATTR_NET_PEER_NAME]: this.config?.server, + [NET_PEER_NAME]: this.config?.server, // eslint-disable-next-line typescript/no-deprecated - [ATTR_NET_PEER_PORT]: this.config?.options?.port, + [NET_PEER_PORT]: this.config?.options?.port, }; const span = startInactiveSpan({ name: getSpanName(operation, databaseName, sql, request.table), diff --git a/packages/node/src/integrations/tracing/tedious/vendored/semconv.ts b/packages/node/src/integrations/tracing/tedious/vendored/semconv.ts index 4b999bed7ff5..da4fe8c816b4 100644 --- a/packages/node/src/integrations/tracing/tedious/vendored/semconv.ts +++ b/packages/node/src/integrations/tracing/tedious/vendored/semconv.ts @@ -13,18 +13,6 @@ * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv */ -/** - * Deprecated, use `db.namespace` instead. - * - * @example customers - * @example main - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `db.namespace`. - */ -export const ATTR_DB_NAME = 'db.name' as const; - /** * Deprecated, use `db.collection.name` instead. * @@ -37,62 +25,7 @@ export const ATTR_DB_NAME = 'db.name' as const; export const ATTR_DB_SQL_TABLE = 'db.sql.table' as const; /** - * The database statement being executed. - * - * @example SELECT * FROM wuser_table - * @example SET mykey "WuValue" - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `db.query.text`. - */ -export const ATTR_DB_STATEMENT = 'db.statement' as const; - -/** - * Deprecated, use `db.system.name` instead. - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `db.system.name`. - */ -export const ATTR_DB_SYSTEM = 'db.system' as const; - -/** - * Deprecated, no replacement at this time. - * - * @example readonly_user - * @example reporting_user - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Removed, no replacement at this time. - */ -export const ATTR_DB_USER = 'db.user' as const; - -/** - * Deprecated, use `server.address` on client spans and `client.address` on server spans. - * - * @example example.com - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans. - */ -export const ATTR_NET_PEER_NAME = 'net.peer.name' as const; - -/** - * Deprecated, use `server.port` on client spans and `client.port` on server spans. - * - * @example 8080 - * - * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`. - * - * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans. - */ -export const ATTR_NET_PEER_PORT = 'net.peer.port' as const; - -/** - * Enum value "mssql" for attribute {@link ATTR_DB_SYSTEM}. + * Enum value "mssql" for attribute `db.system`. * * Microsoft SQL Server * From 71ee392417bf3a9751551782474ad28af91f19a5 Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 1 Jul 2026 17:13:33 +0200 Subject: [PATCH 2/2] Use per-line typescript/no-deprecated opt-outs instead of whole-file disables --- .../src/integrations/tracing/amqplib/vendored/utils.ts | 6 ++++-- .../integrations/tracing/mongoose/vendored/mongoose.ts | 4 ++-- .../integrations/tracing/mongoose/vendored/utils.ts | 6 ++++-- .../tracing/mysql2/vendored/instrumentation.ts | 4 ++-- .../src/integrations/tracing/mysql2/vendored/utils.ts | 5 +++-- .../tracing/redis/vendored/ioredis-instrumentation.ts | 10 ++++++++-- .../tracing/redis/vendored/redis-instrumentation.ts | 10 ++++++++-- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts b/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts index 0378dee312d2..e9cc669331a3 100644 --- a/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts +++ b/packages/node/src/integrations/tracing/amqplib/vendored/utils.ts @@ -12,8 +12,6 @@ * - Replaced the OTel context-key confirm-channel marker with a synchronous flag on the channel instance */ -/* oxlint-disable typescript/no-deprecated */ - import { SpanKind } from '@opentelemetry/api'; import type { Span, SpanAttributes } from '@sentry/core'; import { getTraceData, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core'; @@ -117,7 +115,9 @@ export const getConnectionAttributesFromUrl = (url: string | Options.Connect): S const protocol = getProtocol(connectOptions?.protocol); attributes[ATTR_MESSAGING_PROTOCOL] = protocol; + // oxlint-disable-next-line typescript/no-deprecated attributes[NET_PEER_NAME] = getHostname(connectOptions?.hostname); + // oxlint-disable-next-line typescript/no-deprecated attributes[NET_PEER_PORT] = getPort(connectOptions.port, protocol); } else { const censoredUrl = censorPassword(resolvedUrl); @@ -127,7 +127,9 @@ export const getConnectionAttributesFromUrl = (url: string | Options.Connect): S const protocol = getProtocol(urlParts.protocol); attributes[ATTR_MESSAGING_PROTOCOL] = protocol; + // oxlint-disable-next-line typescript/no-deprecated attributes[NET_PEER_NAME] = getHostname(urlParts.hostname); + // oxlint-disable-next-line typescript/no-deprecated attributes[NET_PEER_PORT] = getPort(urlParts.port ? parseInt(urlParts.port) : undefined, protocol); } catch { // best-effort: a malformed url simply yields fewer connection attributes diff --git a/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts b/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts index 956b64923ba5..da8594a1b808 100644 --- a/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts +++ b/packages/node/src/integrations/tracing/mongoose/vendored/mongoose.ts @@ -10,8 +10,6 @@ * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs */ -/* oxlint-disable typescript/no-deprecated */ - import { type InstrumentationConfig, InstrumentationBase, @@ -299,7 +297,9 @@ export class MongooseInstrumentation extends InstrumentationBase