From daf9c0ef4f03c766a89cf4a308714f7448328d45 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Jun 2026 11:27:44 +0200 Subject: [PATCH] ref(aws-serverless): Use `@sentry/conventions` Source span attribute keys from `@sentry/conventions/attributes` instead of the locally vendored `./semconv` constants (and `@opentelemetry/semantic-conventions`), for the attributes that have a `@sentry/conventions` equivalent. AWS/FAAS-specific keys with no equivalent (e.g. `aws.*`, `faas.execution`, `faas.id`, `gen_ai.request.stop_sequences`, `rpc.system`) remain vendored locally. No functional change. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/aws-serverless/package.json | 2 +- .../src/integration/aws/vendored/aws-sdk.ts | 6 +- .../src/integration/aws/vendored/semconv.ts | 213 ------------------ .../aws/vendored/services/bedrock-runtime.ts | 162 ++++++------- .../aws/vendored/services/dynamodb.ts | 10 +- .../integration/aws/vendored/services/sns.ts | 5 +- .../integration/aws/vendored/services/sqs.ts | 28 +-- .../src/integration/aws/vendored/utils.ts | 7 +- .../instrumentation.ts | 19 +- .../instrumentation-aws-lambda/semconv.ts | 13 +- yarn.lock | 5 + 11 files changed, 133 insertions(+), 337 deletions(-) diff --git a/packages/aws-serverless/package.json b/packages/aws-serverless/package.json index aa846a1eb3b7..99b0c3b9a68f 100644 --- a/packages/aws-serverless/package.json +++ b/packages/aws-serverless/package.json @@ -69,7 +69,7 @@ "@opentelemetry/api": "^1.9.1", "@opentelemetry/core": "^2.6.1", "@opentelemetry/instrumentation": "^0.214.0", - "@opentelemetry/semantic-conventions": "^1.40.0", + "@sentry/conventions": "^0.11.0", "@sentry/core": "10.58.0", "@sentry/node": "10.58.0", "@sentry/node-core": "10.58.0", diff --git a/packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts b/packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts index 124e44a1ca6c..d884762dab79 100644 --- a/packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts +++ b/packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts @@ -46,7 +46,7 @@ import { } from './utils'; import { propwrap } from './propwrap'; import { RequestMetadata } from './services/ServiceExtension'; -import { ATTR_HTTP_STATUS_CODE } from './semconv'; +import { HTTP_STATUS_CODE } from '@sentry/conventions/attributes'; import { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core'; const PACKAGE_NAME = '@sentry/instrumentation-aws-sdk'; @@ -289,7 +289,7 @@ export class AwsInstrumentation extends InstrumentationBase { switch (response.request.commandName) { case 'SendMessage': - span.setAttribute(ATTR_MESSAGING_MESSAGE_ID, response?.data?.MessageId); + span.setAttribute(MESSAGING_MESSAGE_ID, response?.data?.MessageId); break; case 'SendMessageBatch': @@ -119,7 +119,7 @@ export class SqsServiceExtension implements ServiceExtension { case 'ReceiveMessage': { const messages: SQS.Message[] = response?.data?.Messages || []; - span.setAttribute(ATTR_MESSAGING_BATCH_MESSAGE_COUNT, messages.length); + span.setAttribute(MESSAGING_BATCH_MESSAGE_COUNT, messages.length); for (const message of messages) { const propagatedContext = propagation.extract( @@ -134,7 +134,7 @@ export class SqsServiceExtension implements ServiceExtension { span.addLink({ context: spanContext, attributes: { - [ATTR_MESSAGING_MESSAGE_ID]: message.MessageId, + [MESSAGING_MESSAGE_ID]: message.MessageId, }, }); } diff --git a/packages/aws-serverless/src/integration/aws/vendored/utils.ts b/packages/aws-serverless/src/integration/aws/vendored/utils.ts index d8412b9b1566..47ea3aea6938 100644 --- a/packages/aws-serverless/src/integration/aws/vendored/utils.ts +++ b/packages/aws-serverless/src/integration/aws/vendored/utils.ts @@ -19,7 +19,8 @@ */ import { Attributes, Context, context } from '@opentelemetry/api'; -import { ATTR_RPC_METHOD, ATTR_RPC_SERVICE, ATTR_RPC_SYSTEM } from './semconv'; +import { RPC_METHOD, RPC_SERVICE } from '@sentry/conventions/attributes'; +import { ATTR_RPC_SYSTEM } from './semconv'; import { AttributeNames } from './enums'; import { NormalizedRequest } from './types'; @@ -45,8 +46,8 @@ export const normalizeV3Request = ( export const extractAttributesFromNormalizedRequest = (normalizedRequest: NormalizedRequest): Attributes => { return { [ATTR_RPC_SYSTEM]: 'aws-api', - [ATTR_RPC_METHOD]: normalizedRequest.commandName, - [ATTR_RPC_SERVICE]: normalizedRequest.serviceName, + [RPC_METHOD]: normalizedRequest.commandName, + [RPC_SERVICE]: normalizedRequest.serviceName, [AttributeNames.CLOUD_REGION]: normalizedRequest.region, }; }; diff --git a/packages/aws-serverless/src/integration/instrumentation-aws-lambda/instrumentation.ts b/packages/aws-serverless/src/integration/instrumentation-aws-lambda/instrumentation.ts index c564a8dc583a..8241ee1f9dbc 100644 --- a/packages/aws-serverless/src/integration/instrumentation-aws-lambda/instrumentation.ts +++ b/packages/aws-serverless/src/integration/instrumentation-aws-lambda/instrumentation.ts @@ -45,17 +45,12 @@ import { isWrapped, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation'; -import { - ATTR_URL_FULL, - SEMATTRS_FAAS_EXECUTION, - SEMRESATTRS_CLOUD_ACCOUNT_ID, - SEMRESATTRS_FAAS_ID, -} from '@opentelemetry/semantic-conventions'; +import { CLOUD_ACCOUNT_ID, FAAS_COLDSTART, URL_FULL } from '@sentry/conventions/attributes'; import type { APIGatewayProxyEventHeaders, Callback, Context, Handler, StreamifyHandler } from 'aws-lambda'; import * as fs from 'fs'; import * as path from 'path'; import type { LambdaModule } from './internal-types'; -import { ATTR_FAAS_COLDSTART } from './semconv'; +import { ATTR_FAAS_EXECUTION, ATTR_FAAS_ID } from './semconv'; import type { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types'; import { wrapHandler } from '../../sdk'; import { SDK_VERSION } from '@sentry/core'; @@ -338,10 +333,10 @@ export class AwsLambdaInstrumentation extends InstrumentationBase