Skip to content

Commit 4a94311

Browse files
mydeaclaude
andauthored
ref(aws-serverless): Use @sentry/conventions (#21597)
Sources span attribute keys from `@sentry/conventions/attributes` instead of the locally vendored `./semconv` constants (and direct `@opentelemetry/semantic-conventions` imports), for the attributes that have a `@sentry/conventions` equivalent. No functional change — the resolved attribute key strings are identical. Attributes with no `@sentry/conventions` equivalent stay vendored locally: AWS-specific keys (`aws.dynamodb.*`, `aws.sns.topic.arn`, …), `faas.execution`, `faas.id`, `gen_ai.request.stop_sequences`, and `rpc.system`. This supersedes #21491, which was opened before `develop` substantially refactored these vendored files (the `SemconvStability` dual-semconv handling was removed). Rather than rebase through those conflicts, the migration is re-authored on top of current `develop`. Unlike the previous PR, this does **not** add a `paths` override to the shared `packages/typescript/tsconfig.json` — `@sentry/conventions/attributes` resolves via the package's own `exports` map. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 839391f commit 4a94311

19 files changed

Lines changed: 161 additions & 381 deletions

File tree

‎packages/aws-serverless/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@opentelemetry/api": "^1.9.1",
7070
"@opentelemetry/core": "^2.6.1",
7171
"@opentelemetry/instrumentation": "^0.214.0",
72-
"@opentelemetry/semantic-conventions": "^1.40.0",
72+
"@sentry/conventions": "^0.12.0",
7373
"@sentry/core": "10.58.0",
7474
"@sentry/node": "10.58.0",
7575
"@sentry/node-core": "10.58.0",

‎packages/aws-serverless/src/integration/aws/vendored/aws-sdk.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222

2323
import { Span, SpanKind, context, trace, diag, SpanStatusCode } from '@opentelemetry/api';
24-
import { AttributeNames } from './enums';
24+
import { AWS_REQUEST_EXTENDED_ID, AWS_REQUEST_ID, CLOUD_REGION } from './enums';
2525
import { ServicesExtensions } from './services';
2626
import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } from './types';
2727
import {
@@ -46,7 +46,7 @@ import {
4646
} from './utils';
4747
import { propwrap } from './propwrap';
4848
import { RequestMetadata } from './services/ServiceExtension';
49-
import { ATTR_HTTP_STATUS_CODE } from './semconv';
49+
import { HTTP_STATUS_CODE } from '@sentry/conventions/attributes';
5050
import { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startInactiveSpan } from '@sentry/core';
5151

5252
const PACKAGE_NAME = '@sentry/instrumentation-aws-sdk';
@@ -265,7 +265,7 @@ export class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentatio
265265
Promise.resolve(regionPromise)
266266
.then(resolvedRegion => {
267267
normalizedRequest.region = resolvedRegion;
268-
span.setAttribute(AttributeNames.CLOUD_REGION, resolvedRegion);
268+
span.setAttribute(CLOUD_REGION, resolvedRegion);
269269
})
270270
.catch(e => {
271271
// there is nothing much we can do in this case.
@@ -284,18 +284,18 @@ export class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentatio
284284
.then((response: any) => {
285285
const requestId = response.output?.$metadata?.requestId;
286286
if (requestId) {
287-
span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);
287+
span.setAttribute(AWS_REQUEST_ID, requestId);
288288
}
289289

290290
const httpStatusCode = response.output?.$metadata?.httpStatusCode;
291291
if (httpStatusCode) {
292-
// eslint-disable-next-line typescript/no-deprecated
293-
span.setAttribute(ATTR_HTTP_STATUS_CODE, httpStatusCode);
292+
// oxlint-disable-next-line typescript/no-deprecated
293+
span.setAttribute(HTTP_STATUS_CODE, httpStatusCode);
294294
}
295295

296296
const extendedRequestId = response.output?.$metadata?.extendedRequestId;
297297
if (extendedRequestId) {
298-
span.setAttribute(AttributeNames.AWS_REQUEST_EXTENDED_ID, extendedRequestId);
298+
span.setAttribute(AWS_REQUEST_EXTENDED_ID, extendedRequestId);
299299
}
300300

301301
const normalizedResponse: NormalizedResponse = {
@@ -313,18 +313,18 @@ export class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentatio
313313
.catch((err: any) => {
314314
const requestId = err?.RequestId;
315315
if (requestId) {
316-
span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);
316+
span.setAttribute(AWS_REQUEST_ID, requestId);
317317
}
318318

319319
const httpStatusCode = err?.$metadata?.httpStatusCode;
320320
if (httpStatusCode) {
321-
// eslint-disable-next-line typescript/no-deprecated
322-
span.setAttribute(ATTR_HTTP_STATUS_CODE, httpStatusCode);
321+
// oxlint-disable-next-line typescript/no-deprecated
322+
span.setAttribute(HTTP_STATUS_CODE, httpStatusCode);
323323
}
324324

325325
const extendedRequestId = err?.extendedRequestId;
326326
if (extendedRequestId) {
327-
span.setAttribute(AttributeNames.AWS_REQUEST_EXTENDED_ID, extendedRequestId);
327+
span.setAttribute(AWS_REQUEST_EXTENDED_ID, extendedRequestId);
328328
}
329329

330330
span.setStatus({

‎packages/aws-serverless/src/integration/aws/vendored/enums.ts‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,8 @@
1818
* - Upstream version: @opentelemetry/instrumentation-aws-sdk@0.73.0
1919
*/
2020

21-
export enum AttributeNames {
22-
AWS_OPERATION = 'aws.operation',
23-
CLOUD_REGION = 'cloud.region',
24-
AWS_SERVICE_API = 'aws.service.api',
25-
AWS_SERVICE_NAME = 'aws.service.name',
26-
AWS_SERVICE_IDENTIFIER = 'aws.service.identifier',
27-
AWS_REQUEST_ID = 'aws.request.id',
28-
AWS_REQUEST_EXTENDED_ID = 'aws.request.extended_id',
29-
AWS_SIGNATURE_VERSION = 'aws.signature.version',
30-
31-
// TODO: Add these semantic attributes to:
32-
// - https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-semantic-conventions/src/trace/SemanticAttributes.ts
33-
// For S3, see specification: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/object-stores/s3.md
34-
AWS_S3_BUCKET = 'aws.s3.bucket',
35-
AWS_KINESIS_STREAM_NAME = 'aws.kinesis.stream.name',
36-
}
21+
export const CLOUD_REGION = 'cloud.region';
22+
export const AWS_REQUEST_ID = 'aws.request.id';
23+
export const AWS_REQUEST_EXTENDED_ID = 'aws.request.extended_id';
24+
export const AWS_S3_BUCKET = 'aws.s3.bucket';
25+
export const AWS_KINESIS_STREAM_NAME = 'aws.kinesis.stream.name';

‎packages/aws-serverless/src/integration/aws/vendored/semconv.ts‎

Lines changed: 0 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -251,52 +251,6 @@ export const ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN = 'aws.step_functions.activity
251251
*/
252252
export const ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN = 'aws.step_functions.state_machine.arn' as const;
253253

254-
/**
255-
* Deprecated, use `db.namespace` instead.
256-
*
257-
* @example customers
258-
* @example main
259-
*
260-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
261-
*
262-
* @deprecated Replaced by `db.namespace`.
263-
*/
264-
export const ATTR_DB_NAME = 'db.name' as const;
265-
266-
/**
267-
* Deprecated, use `db.operation.name` instead.
268-
*
269-
* @example findAndModify
270-
* @example HMSET
271-
* @example SELECT
272-
*
273-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
274-
*
275-
* @deprecated Replaced by `db.operation.name`.
276-
*/
277-
export const ATTR_DB_OPERATION = 'db.operation' as const;
278-
279-
/**
280-
* The database statement being executed.
281-
*
282-
* @example SELECT * FROM wuser_table
283-
* @example SET mykey "WuValue"
284-
*
285-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
286-
*
287-
* @deprecated Replaced by `db.query.text`.
288-
*/
289-
export const ATTR_DB_STATEMENT = 'db.statement' as const;
290-
291-
/**
292-
* Deprecated, use `db.system.name` instead.
293-
*
294-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
295-
*
296-
* @deprecated Replaced by `db.system.name`.
297-
*/
298-
export const ATTR_DB_SYSTEM = 'db.system' as const;
299-
300254
/**
301255
* The name of the invoked function.
302256
*
@@ -328,33 +282,6 @@ export const ATTR_FAAS_INVOKED_PROVIDER = 'faas.invoked_provider' as const;
328282
*/
329283
export const ATTR_FAAS_INVOKED_REGION = 'faas.invoked_region' as const;
330284

331-
/**
332-
* The name of the operation being performed.
333-
*
334-
* @note If one of the predefined values applies, but specific system uses a different name it's **RECOMMENDED** to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries **SHOULD** use applicable predefined value.
335-
*
336-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
337-
*/
338-
export const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const;
339-
340-
/**
341-
* The maximum number of tokens the model generates for a request.
342-
*
343-
* @example 100
344-
*
345-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
346-
*/
347-
export const ATTR_GEN_AI_REQUEST_MAX_TOKENS = 'gen_ai.request.max_tokens' as const;
348-
349-
/**
350-
* The name of the GenAI model a request is being made to.
351-
*
352-
* @example "gpt-4"
353-
*
354-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
355-
*/
356-
export const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;
357-
358285
/**
359286
* List of sequences that the model will use to stop generating further tokens.
360287
*
@@ -364,43 +291,6 @@ export const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;
364291
*/
365292
export const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES = 'gen_ai.request.stop_sequences' as const;
366293

367-
/**
368-
* The temperature setting for the GenAI request.
369-
*
370-
* @example 0.0
371-
*
372-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
373-
*/
374-
export const ATTR_GEN_AI_REQUEST_TEMPERATURE = 'gen_ai.request.temperature' as const;
375-
376-
/**
377-
* The top_p sampling setting for the GenAI request.
378-
*
379-
* @example 1.0
380-
*
381-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
382-
*/
383-
export const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const;
384-
385-
/**
386-
* Array of reasons the model stopped generating tokens, corresponding to each generation received.
387-
*
388-
* @example ["stop"]
389-
* @example ["stop", "length"]
390-
*
391-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
392-
*/
393-
export const ATTR_GEN_AI_RESPONSE_FINISH_REASONS = 'gen_ai.response.finish_reasons' as const;
394-
395-
/**
396-
* Deprecated, use `gen_ai.provider.name` instead.
397-
*
398-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
399-
*
400-
* @deprecated Replaced by `gen_ai.provider.name`.
401-
*/
402-
export const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;
403-
404294
/**
405295
* The type of token being counted.
406296
*
@@ -411,70 +301,6 @@ export const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;
411301
*/
412302
export const ATTR_GEN_AI_TOKEN_TYPE = 'gen_ai.token.type' as const;
413303

414-
/**
415-
* The number of tokens used in the GenAI input (prompt).
416-
*
417-
* @example 100
418-
*
419-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
420-
*/
421-
export const ATTR_GEN_AI_USAGE_INPUT_TOKENS = 'gen_ai.usage.input_tokens' as const;
422-
423-
/**
424-
* The number of tokens used in the GenAI response (completion).
425-
*
426-
* @example 180
427-
*
428-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
429-
*/
430-
export const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS = 'gen_ai.usage.output_tokens' as const;
431-
432-
/**
433-
* Deprecated, use `http.response.status_code` instead.
434-
*
435-
* @example 200
436-
*
437-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
438-
*
439-
* @deprecated Replaced by `http.response.status_code`.
440-
*/
441-
export const ATTR_HTTP_STATUS_CODE = 'http.status_code' as const;
442-
443-
/**
444-
* The number of messages sent, received, or processed in the scope of the batching operation.
445-
*
446-
* @example 0
447-
* @example 1
448-
* @example 2
449-
*
450-
* @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.
451-
*
452-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
453-
*/
454-
export const ATTR_MESSAGING_BATCH_MESSAGE_COUNT = 'messaging.batch.message_count' as const;
455-
456-
/**
457-
* The message destination name
458-
*
459-
* @example MyQueue
460-
* @example MyTopic
461-
*
462-
* @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If
463-
* the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.
464-
*
465-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
466-
*/
467-
export const ATTR_MESSAGING_DESTINATION_NAME = 'messaging.destination.name' as const;
468-
469-
/**
470-
* A value used by the messaging system as an identifier for the message, represented as a string.
471-
*
472-
* @example "452a7c7c7c7048c2f887f61572b18fc2"
473-
*
474-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
475-
*/
476-
export const ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;
477-
478304
/**
479305
* Deprecated, use `messaging.operation.type` instead.
480306
*
@@ -488,45 +314,6 @@ export const ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;
488314
*/
489315
export const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const;
490316

491-
/**
492-
* A string identifying the type of the messaging operation.
493-
*
494-
* @note If a custom value is used, it **MUST** be of low cardinality.
495-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
496-
*/
497-
export const ATTR_MESSAGING_OPERATION_TYPE = 'messaging.operation.type' as const;
498-
499-
/**
500-
* The messaging system as identified by the client instrumentation.
501-
*
502-
* @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.
503-
*
504-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
505-
*/
506-
export const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;
507-
508-
/**
509-
* The name of the (logical) method being called, must be equal to the $method part in the span name.
510-
*
511-
* @example "exampleMethod"
512-
*
513-
* @note This is the logical name of the method from the RPC interface perspective, which can be different from the name of any implementing method/function. The `code.function.name` attribute may be used to store the latter (e.g., method actually executing the call on the server side, RPC client stub method on the client side).
514-
*
515-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
516-
*/
517-
export const ATTR_RPC_METHOD = 'rpc.method' as const;
518-
519-
/**
520-
* The full (logical) name of the service being called, including its package name, if applicable.
521-
*
522-
* @example "myservice.EchoService"
523-
*
524-
* @note This is the logical name of the service from the RPC interface perspective, which can be different from the name of any implementing class. The `code.namespace` attribute may be used to store the latter (despite the attribute name, it may include a class name; e.g., class with method actually executing the call on the server side, RPC client stub class on the client side).
525-
*
526-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
527-
*/
528-
export const ATTR_RPC_SERVICE = 'rpc.service' as const;
529-
530317
/**
531318
* A string identifying the remoting system. See below for a list of well-known identifiers.
532319
*

0 commit comments

Comments
 (0)