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
1 change: 0 additions & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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,
Expand All @@ -24,10 +25,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,
Expand Down Expand Up @@ -99,7 +97,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 {};
Expand All @@ -117,8 +115,10 @@ 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);
// 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);
attributes[ATTR_MESSAGING_URL] = censoredUrl;
Expand All @@ -127,8 +127,10 @@ 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);
// 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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -265,7 +265,7 @@ export class FastifyInstrumentationV3 extends InstrumentationBase<FastifyInstrum
[AttributeNames.PLUGIN_NAME]: this.pluginName,
[AttributeNames.FASTIFY_TYPE]: FastifyTypes.REQUEST_HANDLER,
// eslint-disable-next-line typescript/no-deprecated
[SEMATTRS_HTTP_ROUTE]: anyRequest.routeOptions
[HTTP_ROUTE]: anyRequest.routeOptions
? anyRequest.routeOptions.url // since fastify@4.10.0
: request.routerPath,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as net from 'node:net';
import { InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
import { InstrumentationNodeModuleFile } from '../../../InstrumentationNodeModuleFile';
import {
ATTR_DB_COLLECTION_NAME,
ATTR_DB_NAMESPACE,
ATTR_DB_OPERATION_NAME,
ATTR_DB_SYSTEM_NAME,
ATTR_SERVER_ADDRESS,
ATTR_SERVER_PORT,
} from '@opentelemetry/semantic-conventions';
DB_COLLECTION_NAME,
DB_NAMESPACE,
DB_OPERATION_NAME,
DB_SYSTEM_NAME,
SERVER_ADDRESS,
SERVER_PORT,
} from '@sentry/conventions/attributes';
import type { SpanAttributes } from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_KIND, startSpan } from '@sentry/core';
import type { FirebaseInstrumentation } from '../firebaseInstrumentation';
Expand Down Expand Up @@ -181,7 +181,7 @@ function startFirestoreSpan<AppModelType, DbModelType extends DocumentData, T>(
kind: SPAN_KIND.CLIENT,
attributes: {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.firebase.otel.firestore',
[ATTR_DB_OPERATION_NAME]: spanName,
[DB_OPERATION_NAME]: spanName,
...buildAttributes(reference),
},
},
Expand Down Expand Up @@ -248,9 +248,9 @@ function buildAttributes<AppModelType, DbModelType extends DocumentData>(
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,
Expand All @@ -261,10 +261,10 @@ function buildAttributes<AppModelType, DbModelType extends DocumentData>(
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;
Expand Down
22 changes: 0 additions & 22 deletions packages/node/src/integrations/tracing/hapi/vendored/semconv.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/node/src/integrations/tracing/hono/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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}`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -191,7 +191,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<InstrumentationC
message: undefined,
operationType: MESSAGING_OPERATION_TYPE_VALUE_RECEIVE,
attributes: {
[ATTR_MESSAGING_BATCH_MESSAGE_COUNT]: payload.batch.messages.length,
[MESSAGING_BATCH_MESSAGE_COUNT]: payload.batch.messages.length,
[ATTR_MESSAGING_DESTINATION_PARTITION_ID]: String(payload.batch.partition),
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
*/

/**
* The number of messages sent, received, or processed in the scope of the batching operation.
*
* @example 0
* @example 1
* @example 2
*
* @note Instrumentations **SHOULD NOT** set `messaging.batch.message_count` on spans that operate with a single message. When a messaging client library supports both batch and single-message API for the same operation, instrumentations **SHOULD** use `messaging.batch.message_count` for batching APIs and **SHOULD NOT** use it for single-message APIs.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_MESSAGING_BATCH_MESSAGE_COUNT = 'messaging.batch.message_count' as const;

/**
* The message destination name
*
* @example MyQueue
* @example MyTopic
*
* @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If
* the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_MESSAGING_DESTINATION_NAME = 'messaging.destination.name' as const;

/**
* The identifier of the partition messages are sent to or received from, unique within the `messaging.destination.name`.
*
Expand Down Expand Up @@ -77,65 +51,27 @@ export const ATTR_MESSAGING_KAFKA_MESSAGE_TOMBSTONE = 'messaging.kafka.message.t
export const ATTR_MESSAGING_KAFKA_OFFSET = 'messaging.kafka.offset' as const;

/**
* The system-specific name of the messaging operation.
*
* @example ack
* @example nack
* @example send
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_MESSAGING_OPERATION_NAME = 'messaging.operation.name' as const;

/**
* A string identifying the type of the messaging operation.
*
* @note If a custom value is used, it **MUST** be of low cardinality.
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_MESSAGING_OPERATION_TYPE = 'messaging.operation.type' as const;

/**
* The messaging system as identified by the client instrumentation.
*
* @note The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the `messaging.system` is set to `kafka` based on the instrumentation's best knowledge.
*
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
*/
export const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;

/**
* Enum value "process" for attribute {@link ATTR_MESSAGING_OPERATION_TYPE}.
* Enum value "process" for attribute `messaging.operation.type`.
*/
export const MESSAGING_OPERATION_TYPE_VALUE_PROCESS = 'process' as const;

/**
* Enum value "receive" for attribute {@link ATTR_MESSAGING_OPERATION_TYPE}.
* Enum value "receive" for attribute `messaging.operation.type`.
*/
export const MESSAGING_OPERATION_TYPE_VALUE_RECEIVE = 'receive' as const;

/**
* Enum value "send" for attribute {@link ATTR_MESSAGING_OPERATION_TYPE}.
* Enum value "send" for attribute `messaging.operation.type`.
*/
export const MESSAGING_OPERATION_TYPE_VALUE_SEND = 'send' as const;

/**
* Enum value "kafka" for attribute {@link ATTR_MESSAGING_SYSTEM}.
* Enum value "kafka" for attribute `messaging.system`.
*/
export const MESSAGING_SYSTEM_VALUE_KAFKA = 'kafka' as const;

/**
* Describes a class of error the operation ended with.
*
* @example timeout
* @example java.net.UnknownHostException
* @example server_certificate_invalid
* @example 500
*/
export const ATTR_ERROR_TYPE = 'error.type' as const;

/**
* Enum value "_OTHER" for attribute {@link ATTR_ERROR_TYPE}. A fallback error value to be used when
* Enum value "_OTHER" for attribute `error.type`. A fallback error value to be used when
* the instrumentation doesn't define a custom value.
*/
export const ERROR_TYPE_VALUE_OTHER = '_OTHER' as const;
Loading
Loading