@opentelemetry/instrumentation-aws-sdk 0.61.2 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"aws-sdk.types.js","sourceRoot":"","sources":["../../src/aws-sdk.types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * AWS SDK for JavaScript\n * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * This product includes software developed at\n * Amazon Web Services, Inc. (http://aws.amazon.com/).\n */\n\n/*\n These are slightly modified and simplified versions of the actual SQS types included\n in the official distribution:\n https://github.com/aws/aws-sdk-js/blob/master/clients/sqs.d.ts\n These are brought here to avoid having users install the `aws-sdk` whenever they\n require this instrumentation.\n*/\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface -- Our lint doesn't like it, but we prefer to keep it the way original source code has it\ninterface Blob {}\ntype Binary = Buffer | Uint8Array | Blob | string;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace -- Prefer to contain the types copied over in one location\nexport namespace SNS {\n interface MessageAttributeValue {\n /**\n * Amazon SNS supports the following logical data types: String, String.Array, Number, and Binary. For more information, see Message Attribute Data Types.\n */\n DataType: string;\n /**\n * Strings are Unicode with UTF8 binary encoding. For a list of code values, see ASCII Printable Characters.\n */\n StringValue?: string;\n /**\n * Binary type attributes can store any binary data, for example, compressed data, encrypted data, or images.\n */\n BinaryValue?: Binary;\n }\n\n export type MessageAttributeMap = { [key: string]: MessageAttributeValue };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace -- Prefer to contain the types copied over in one location\nexport namespace SQS {\n type StringList = string[];\n type BinaryList = Binary[];\n interface MessageAttributeValue {\n /**\n * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters.\n */\n StringValue?: string;\n /**\n * Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.\n */\n BinaryValue?: Binary;\n /**\n * Not implemented. Reserved for future use.\n */\n StringListValues?: StringList;\n /**\n * Not implemented. Reserved for future use.\n */\n BinaryListValues?: BinaryList;\n /**\n * Amazon SQS supports the following logical data types: String, Number, and Binary. For the Number data type, you must use StringValue. You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.\n */\n DataType: string;\n }\n\n export type MessageBodyAttributeMap = {\n [key: string]: MessageAttributeValue;\n };\n\n type MessageSystemAttributeMap = { [key: string]: string };\n\n export interface Message {\n /**\n * A unique identifier for the message. A MessageId is considered unique across all accounts for an extended period of time.\n */\n MessageId?: string;\n /**\n * An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.\n */\n ReceiptHandle?: string;\n /**\n * An MD5 digest of the non-URL-encoded message body string.\n */\n MD5OfBody?: string;\n /**\n * The message's contents (not URL-encoded).\n */\n Body?: string;\n /**\n * A map of the attributes requested in ReceiveMessage to their respective values. Supported attributes: ApproximateReceiveCount ApproximateFirstReceiveTimestamp MessageDeduplicationId MessageGroupId SenderId SentTimestamp SequenceNumber ApproximateFirstReceiveTimestamp and SentTimestamp are each returned as an integer representing the epoch time in milliseconds.\n */\n Attributes?: MessageSystemAttributeMap;\n /**\n * An MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see RFC1321.\n */\n MD5OfMessageAttributes?: string;\n /**\n * Each message attribute consists of a Name, Type, and Value. For more information, see Amazon SQS message attributes in the Amazon SQS Developer Guide.\n */\n MessageAttributes?: MessageBodyAttributeMap;\n }\n}\n"]}
1
+ {"version":3,"file":"aws-sdk.types.js","sourceRoot":"","sources":["../../src/aws-sdk.types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * AWS SDK for JavaScript\n * Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n * This product includes software developed at\n * Amazon Web Services, Inc. (http://aws.amazon.com/).\n */\n\n/*\n These are slightly modified and simplified versions of the actual SQS types included\n in the official distribution:\n https://github.com/aws/aws-sdk-js/blob/master/clients/sqs.d.ts\n These are brought here to avoid having users install the `aws-sdk` whenever they\n require this instrumentation.\n*/\n\ninterface Blob {}\ntype Binary = Buffer | Uint8Array | Blob | string;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace -- Prefer to contain the types copied over in one location\nexport namespace SNS {\n interface MessageAttributeValue {\n /**\n * Amazon SNS supports the following logical data types: String, String.Array, Number, and Binary. For more information, see Message Attribute Data Types.\n */\n DataType: string;\n /**\n * Strings are Unicode with UTF8 binary encoding. For a list of code values, see ASCII Printable Characters.\n */\n StringValue?: string;\n /**\n * Binary type attributes can store any binary data, for example, compressed data, encrypted data, or images.\n */\n BinaryValue?: Binary;\n }\n\n export type MessageAttributeMap = { [key: string]: MessageAttributeValue };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-namespace -- Prefer to contain the types copied over in one location\nexport namespace SQS {\n type StringList = string[];\n type BinaryList = Binary[];\n interface MessageAttributeValue {\n /**\n * Strings are Unicode with UTF-8 binary encoding. For a list of code values, see ASCII Printable Characters.\n */\n StringValue?: string;\n /**\n * Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.\n */\n BinaryValue?: Binary;\n /**\n * Not implemented. Reserved for future use.\n */\n StringListValues?: StringList;\n /**\n * Not implemented. Reserved for future use.\n */\n BinaryListValues?: BinaryList;\n /**\n * Amazon SQS supports the following logical data types: String, Number, and Binary. For the Number data type, you must use StringValue. You can also append custom labels. For more information, see Amazon SQS Message Attributes in the Amazon SQS Developer Guide.\n */\n DataType: string;\n }\n\n export type MessageBodyAttributeMap = {\n [key: string]: MessageAttributeValue;\n };\n\n type MessageSystemAttributeMap = { [key: string]: string };\n\n export interface Message {\n /**\n * A unique identifier for the message. A MessageId is considered unique across all accounts for an extended period of time.\n */\n MessageId?: string;\n /**\n * An identifier associated with the act of receiving the message. A new receipt handle is returned every time you receive a message. When deleting a message, you provide the last received receipt handle to delete the message.\n */\n ReceiptHandle?: string;\n /**\n * An MD5 digest of the non-URL-encoded message body string.\n */\n MD5OfBody?: string;\n /**\n * The message's contents (not URL-encoded).\n */\n Body?: string;\n /**\n * A map of the attributes requested in ReceiveMessage to their respective values. Supported attributes: ApproximateReceiveCount ApproximateFirstReceiveTimestamp MessageDeduplicationId MessageGroupId SenderId SentTimestamp SequenceNumber ApproximateFirstReceiveTimestamp and SentTimestamp are each returned as an integer representing the epoch time in milliseconds.\n */\n Attributes?: MessageSystemAttributeMap;\n /**\n * An MD5 digest of the non-URL-encoded message attribute string. You can use this attribute to verify that Amazon SQS received the message correctly. Amazon SQS URL-decodes the message before creating the MD5 digest. For information about MD5, see RFC1321.\n */\n MD5OfMessageAttributes?: string;\n /**\n * Each message attribute consists of a Name, Type, and Value. For more information, see Amazon SQS message attributes in the Amazon SQS Developer Guide.\n */\n MessageAttributes?: MessageBodyAttributeMap;\n }\n}\n"]}
@@ -495,4 +495,16 @@ export declare const GEN_AI_TOKEN_TYPE_VALUE_INPUT: "input";
495
495
  * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
496
496
  */
497
497
  export declare const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT: "output";
498
+ /**
499
+ * GenAI operation duration.
500
+ *
501
+ * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
502
+ */
503
+ export declare const METRIC_GEN_AI_CLIENT_OPERATION_DURATION: "gen_ai.client.operation.duration";
504
+ /**
505
+ * Number of input and output tokens used.
506
+ *
507
+ * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
508
+ */
509
+ export declare const METRIC_GEN_AI_CLIENT_TOKEN_USAGE: "gen_ai.client.token.usage";
498
510
  //# sourceMappingURL=semconv.d.ts.map
@@ -16,7 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.ATTR_MESSAGING_SYSTEM = exports.ATTR_MESSAGING_OPERATION_TYPE = exports.ATTR_MESSAGING_OPERATION = exports.ATTR_MESSAGING_MESSAGE_ID = exports.ATTR_MESSAGING_DESTINATION_NAME = exports.ATTR_MESSAGING_BATCH_MESSAGE_COUNT = exports.ATTR_HTTP_STATUS_CODE = exports.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS = exports.ATTR_GEN_AI_USAGE_INPUT_TOKENS = exports.ATTR_GEN_AI_TOKEN_TYPE = exports.ATTR_GEN_AI_SYSTEM = exports.ATTR_GEN_AI_RESPONSE_FINISH_REASONS = exports.ATTR_GEN_AI_REQUEST_TOP_P = exports.ATTR_GEN_AI_REQUEST_TEMPERATURE = exports.ATTR_GEN_AI_REQUEST_STOP_SEQUENCES = exports.ATTR_GEN_AI_REQUEST_MODEL = exports.ATTR_GEN_AI_REQUEST_MAX_TOKENS = exports.ATTR_GEN_AI_OPERATION_NAME = exports.ATTR_FAAS_INVOKED_REGION = exports.ATTR_FAAS_INVOKED_PROVIDER = exports.ATTR_FAAS_INVOKED_NAME = exports.ATTR_DB_SYSTEM = exports.ATTR_DB_STATEMENT = exports.ATTR_DB_OPERATION = exports.ATTR_DB_NAME = exports.ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN = exports.ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN = exports.ATTR_AWS_SNS_TOPIC_ARN = exports.ATTR_AWS_SECRETSMANAGER_SECRET_ARN = exports.ATTR_AWS_DYNAMODB_TOTAL_SEGMENTS = exports.ATTR_AWS_DYNAMODB_TABLE_NAMES = exports.ATTR_AWS_DYNAMODB_TABLE_COUNT = exports.ATTR_AWS_DYNAMODB_SELECT = exports.ATTR_AWS_DYNAMODB_SEGMENT = exports.ATTR_AWS_DYNAMODB_SCAN_FORWARD = exports.ATTR_AWS_DYNAMODB_SCANNED_COUNT = exports.ATTR_AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY = exports.ATTR_AWS_DYNAMODB_PROVISIONED_READ_CAPACITY = exports.ATTR_AWS_DYNAMODB_PROJECTION = exports.ATTR_AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES = exports.ATTR_AWS_DYNAMODB_LIMIT = exports.ATTR_AWS_DYNAMODB_ITEM_COLLECTION_METRICS = exports.ATTR_AWS_DYNAMODB_INDEX_NAME = exports.ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES = exports.ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES = exports.ATTR_AWS_DYNAMODB_EXCLUSIVE_START_TABLE = exports.ATTR_AWS_DYNAMODB_COUNT = exports.ATTR_AWS_DYNAMODB_CONSUMED_CAPACITY = exports.ATTR_AWS_DYNAMODB_CONSISTENT_READ = exports.ATTR_AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS = void 0;
19
- exports.GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = exports.GEN_AI_TOKEN_TYPE_VALUE_INPUT = exports.GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = exports.GEN_AI_OPERATION_NAME_VALUE_CHAT = exports.DB_SYSTEM_VALUE_DYNAMODB = exports.ATTR_RPC_SYSTEM = exports.ATTR_RPC_SERVICE = exports.ATTR_RPC_METHOD = void 0;
19
+ exports.METRIC_GEN_AI_CLIENT_TOKEN_USAGE = exports.METRIC_GEN_AI_CLIENT_OPERATION_DURATION = exports.GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = exports.GEN_AI_TOKEN_TYPE_VALUE_INPUT = exports.GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = exports.GEN_AI_OPERATION_NAME_VALUE_CHAT = exports.DB_SYSTEM_VALUE_DYNAMODB = exports.ATTR_RPC_SYSTEM = exports.ATTR_RPC_SERVICE = exports.ATTR_RPC_METHOD = void 0;
20
20
  /*
21
21
  * This file contains a copy of unstable semantic convention definitions
22
22
  * used by this package.
@@ -519,4 +519,16 @@ exports.GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input';
519
519
  * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
520
520
  */
521
521
  exports.GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output';
522
+ /**
523
+ * GenAI operation duration.
524
+ *
525
+ * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
526
+ */
527
+ exports.METRIC_GEN_AI_CLIENT_OPERATION_DURATION = 'gen_ai.client.operation.duration';
528
+ /**
529
+ * Number of input and output tokens used.
530
+ *
531
+ * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
532
+ */
533
+ exports.METRIC_GEN_AI_CLIENT_TOKEN_USAGE = 'gen_ai.client.token.usage';
522
534
  //# sourceMappingURL=semconv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH;;;;;;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oC,CAAC;AAEvC;;;;;;GAMG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;;;;;GAQG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;;;GAUG;AACU,QAAA,kCAAkC,GAC7C,+BAAwC,CAAC;AAE3C;;;;;;;;;;GAUG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,sBAA+B,CAAC;AAEzE;;;;;;;;;;GAUG;AACU,QAAA,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;GAKG;AACU,QAAA,6BAA6B,GACxC,0BAAmC,CAAC;AAEtC;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACU,QAAA,eAAe,GAAG,YAAqB,CAAC;AAErD;;;;;;;;GAQG;AACU,QAAA,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;GAIG;AACU,QAAA,eAAe,GAAG,YAAqB,CAAC;AAErD;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAG,UAAmB,CAAC;AAE5D;;;;;;GAMG;AACU,QAAA,gCAAgC,GAAG,MAAe,CAAC;AAEhE;;;;;;GAMG;AACU,QAAA,+BAA+B,GAAG,aAAsB,CAAC;AAEtE;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,OAAgB,CAAC;AAE9D;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAG,QAAiB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The JSON-serialized value of each item in the `AttributeDefinitions` request field.\n *\n * @example [\"{ \"AttributeName\": \"string\", \"AttributeType\": \"string\" }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS =\n 'aws.dynamodb.attribute_definitions' as const;\n\n/**\n * The value of the `ConsistentRead` request parameter.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_CONSISTENT_READ =\n 'aws.dynamodb.consistent_read' as const;\n\n/**\n * The JSON-serialized value of each item in the `ConsumedCapacity` response field.\n *\n * @example [\"{ \"CapacityUnits\": number, \"GlobalSecondaryIndexes\": { \"string\" : { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }, \"LocalSecondaryIndexes\": { \"string\" : { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }, \"ReadCapacityUnits\": number, \"Table\": { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number }, \"TableName\": \"string\", \"WriteCapacityUnits\": number }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_CONSUMED_CAPACITY =\n 'aws.dynamodb.consumed_capacity' as const;\n\n/**\n * The value of the `Count` response parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_COUNT = 'aws.dynamodb.count' as const;\n\n/**\n * The value of the `ExclusiveStartTableName` request parameter.\n *\n * @example Users\n * @example CatsTable\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_EXCLUSIVE_START_TABLE =\n 'aws.dynamodb.exclusive_start_table' as const;\n\n/**\n * The JSON-serialized value of each item of the `GlobalSecondaryIndexes` request field\n *\n * @example [\"{ \"IndexName\": \"string\", \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" }, \"ProvisionedThroughput\": { \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES =\n 'aws.dynamodb.global_secondary_indexes' as const;\n\n/**\n * The JSON-serialized value of each item in the `GlobalSecondaryIndexUpdates` request field.\n *\n * @example [\"{ \"Create\": { \"IndexName\": \"string\", \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" }, \"ProvisionedThroughput\": { \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES =\n 'aws.dynamodb.global_secondary_index_updates' as const;\n\n/**\n * The value of the `IndexName` request parameter.\n *\n * @example name_to_group\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_INDEX_NAME = 'aws.dynamodb.index_name' as const;\n\n/**\n * The JSON-serialized value of the `ItemCollectionMetrics` response field.\n *\n * @example { \"string\" : [ { \"ItemCollectionKey\": { \"string\" : { \"B\": blob, \"BOOL\": boolean, \"BS\": [ blob ], \"L\": [ \"AttributeValue\" ], \"M\": { \"string\" : \"AttributeValue\" }, \"N\": \"string\", \"NS\": [ \"string\" ], \"NULL\": boolean, \"S\": \"string\", \"SS\": [ \"string\" ] } }, \"SizeEstimateRangeGB\": [ number ] } ] }\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_ITEM_COLLECTION_METRICS =\n 'aws.dynamodb.item_collection_metrics' as const;\n\n/**\n * The value of the `Limit` request parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_LIMIT = 'aws.dynamodb.limit' as const;\n\n/**\n * The JSON-serialized value of each item of the `LocalSecondaryIndexes` request field.\n *\n * @example [\"{ \"IndexArn\": \"string\", \"IndexName\": \"string\", \"IndexSizeBytes\": number, \"ItemCount\": number, \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES =\n 'aws.dynamodb.local_secondary_indexes' as const;\n\n/**\n * The value of the `ProjectionExpression` request parameter.\n *\n * @example Title\n * @example Title, Price, Color\n * @example Title, Description, RelatedItems, ProductReviews\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROJECTION = 'aws.dynamodb.projection' as const;\n\n/**\n * The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter.\n *\n * @example 1.0\n * @example 2.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROVISIONED_READ_CAPACITY =\n 'aws.dynamodb.provisioned_read_capacity' as const;\n\n/**\n * The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter.\n *\n * @example 1.0\n * @example 2.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY =\n 'aws.dynamodb.provisioned_write_capacity' as const;\n\n/**\n * The value of the `ScannedCount` response parameter.\n *\n * @example 50\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SCANNED_COUNT =\n 'aws.dynamodb.scanned_count' as const;\n\n/**\n * The value of the `ScanIndexForward` request parameter.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SCAN_FORWARD =\n 'aws.dynamodb.scan_forward' as const;\n\n/**\n * The value of the `Segment` request parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SEGMENT = 'aws.dynamodb.segment' as const;\n\n/**\n * The value of the `Select` request parameter.\n *\n * @example ALL_ATTRIBUTES\n * @example COUNT\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SELECT = 'aws.dynamodb.select' as const;\n\n/**\n * The number of items in the `TableNames` response parameter.\n *\n * @example 20\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TABLE_COUNT =\n 'aws.dynamodb.table_count' as const;\n\n/**\n * The keys in the `RequestItems` object field.\n *\n * @example [\"Users\", \"Cats\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TABLE_NAMES =\n 'aws.dynamodb.table_names' as const;\n\n/**\n * The value of the `TotalSegments` request parameter.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TOTAL_SEGMENTS =\n 'aws.dynamodb.total_segments' as const;\n\n/**\n * The ARN of the Secret stored in the Secrets Mangger\n *\n * @example arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretName-6RandomCharacters\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SECRETSMANAGER_SECRET_ARN =\n 'aws.secretsmanager.secret.arn' as const;\n\n/**\n * The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.\n *\n * @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions Activity.\n *\n * @example arn:aws:states:us-east-1:123456789012:activity:get-greeting\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN =\n 'aws.step_functions.activity.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions State Machine.\n *\n * @example arn:aws:states:us-east-1:123456789012:stateMachine:myStateMachine:1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN =\n 'aws.step_functions.state_machine.arn' as const;\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @example customers\n * @example main\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * Deprecated, use `db.operation.name` instead.\n *\n * @example findAndModify\n * @example HMSET\n * @example SELECT\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.operation.name`.\n */\nexport const ATTR_DB_OPERATION = 'db.operation' as const;\n\n/**\n * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * The name of the invoked function.\n *\n * @example \"my-function\"\n *\n * @note **SHOULD** be equal to the `faas.name` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_NAME = 'faas.invoked_name' as const;\n\n/**\n * The cloud provider of the invoked function.\n *\n * @note **SHOULD** be equal to the `cloud.provider` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_PROVIDER = 'faas.invoked_provider' as const;\n\n/**\n * The cloud region of the invoked function.\n *\n * @example \"eu-central-1\"\n *\n * @note **SHOULD** be equal to the `cloud.region` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_REGION = 'faas.invoked_region' as const;\n\n/**\n * The name of the operation being performed.\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const;\n\n/**\n * The maximum number of tokens the model generates for a request.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MAX_TOKENS =\n 'gen_ai.request.max_tokens' as const;\n\n/**\n * The name of the GenAI model a request is being made to.\n *\n * @example \"gpt-4\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;\n\n/**\n * List of sequences that the model will use to stop generating further tokens.\n *\n * @example [\"forest\", \"lived\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES =\n 'gen_ai.request.stop_sequences' as const;\n\n/**\n * The temperature setting for the GenAI request.\n *\n * @example 0.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TEMPERATURE =\n 'gen_ai.request.temperature' as const;\n\n/**\n * The top_p sampling setting for the GenAI request.\n *\n * @example 1.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const;\n\n/**\n * Array of reasons the model stopped generating tokens, corresponding to each generation received.\n *\n * @example [\"stop\"]\n * @example [\"stop\", \"length\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_RESPONSE_FINISH_REASONS =\n 'gen_ai.response.finish_reasons' as const;\n\n/**\n * Deprecated, use `gen_ai.provider.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `gen_ai.provider.name`.\n */\nexport const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;\n\n/**\n * The type of token being counted.\n *\n * @example input\n * @example output\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_TOKEN_TYPE = 'gen_ai.token.type' as const;\n\n/**\n * The number of tokens used in the GenAI input (prompt).\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_INPUT_TOKENS =\n 'gen_ai.usage.input_tokens' as const;\n\n/**\n * The number of tokens used in the GenAI response (completion).\n *\n * @example 180\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS =\n 'gen_ai.usage.output_tokens' as const;\n\n/**\n * Deprecated, use `http.response.status_code` instead.\n *\n * @example 200\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.status_code`.\n */\nexport const ATTR_HTTP_STATUS_CODE = 'http.status_code' as const;\n\n/**\n * The number of messages sent, received, or processed in the scope of the batching operation.\n *\n * @example 0\n * @example 1\n * @example 2\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_BATCH_MESSAGE_COUNT =\n 'messaging.batch.message_count' as const;\n\n/**\n * The message destination name\n *\n * @example MyQueue\n * @example MyTopic\n *\n * @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If\n * the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_DESTINATION_NAME =\n 'messaging.destination.name' as const;\n\n/**\n * A value used by the messaging system as an identifier for the message, represented as a string.\n *\n * @example \"452a7c7c7c7048c2f887f61572b18fc2\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;\n\n/**\n * Deprecated, use `messaging.operation.type` instead.\n *\n * @example publish\n * @example create\n * @example process\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `messaging.operation.type`.\n */\nexport const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const;\n\n/**\n * A string identifying the type of the messaging operation.\n *\n * @note If a custom value is used, it **MUST** be of low cardinality.\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_OPERATION_TYPE =\n 'messaging.operation.type' as const;\n\n/**\n * The messaging system as identified by the client instrumentation.\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;\n\n/**\n * The name of the (logical) method being called, must be equal to the $method part in the span name.\n *\n * @example \"exampleMethod\"\n *\n * @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).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_METHOD = 'rpc.method' as const;\n\n/**\n * The full (logical) name of the service being called, including its package name, if applicable.\n *\n * @example \"myservice.EchoService\"\n *\n * @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).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_SERVICE = 'rpc.service' as const;\n\n/**\n * A string identifying the remoting system. See below for a list of well-known identifiers.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_SYSTEM = 'rpc.system' as const;\n\n/**\n * Enum value \"dynamodb\" for attribute {@link ATTR_DB_SYSTEM}.\n *\n * Amazon DynamoDB\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_VALUE_DYNAMODB = 'dynamodb' as const;\n\n/**\n * Enum value \"chat\" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.\n *\n * Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat' as const;\n\n/**\n * Enum value \"aws.bedrock\" for attribute {@link ATTR_GEN_AI_SYSTEM}.\n *\n * AWS Bedrock\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock' as const;\n\n/**\n * Enum value \"input\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Input tokens (prompt, input, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;\n\n/**\n * Enum value \"output\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Output tokens (completion, response, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;\n"]}
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACU,QAAA,uCAAuC,GAClD,oCAA6C,CAAC;AAEhD;;;;GAIG;AACU,QAAA,iCAAiC,GAC5C,8BAAuC,CAAC;AAE1C;;;;;;GAMG;AACU,QAAA,mCAAmC,GAC9C,gCAAyC,CAAC;AAE5C;;;;;;GAMG;AACU,QAAA,uBAAuB,GAAG,oBAA6B,CAAC;AAErE;;;;;;;GAOG;AACU,QAAA,uCAAuC,GAClD,oCAA6C,CAAC;AAEhD;;;;;;GAMG;AACU,QAAA,0CAA0C,GACrD,uCAAgD,CAAC;AAEnD;;;;;;GAMG;AACU,QAAA,gDAAgD,GAC3D,6CAAsD,CAAC;AAEzD;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,yBAAkC,CAAC;AAE/E;;;;;;GAMG;AACU,QAAA,yCAAyC,G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AEjE;;;;;;;;GAQG;AACU,QAAA,eAAe,GAAG,YAAqB,CAAC;AAErD;;;;;;;;GAQG;AACU,QAAA,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;GAIG;AACU,QAAA,eAAe,GAAG,YAAqB,CAAC;AAErD;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAG,UAAmB,CAAC;AAE5D;;;;;;GAMG;AACU,QAAA,gCAAgC,GAAG,MAAe,CAAC;AAEhE;;;;;;GAMG;AACU,QAAA,+BAA+B,GAAG,aAAsB,CAAC;AAEtE;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,OAAgB,CAAC;AAE9D;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAG,QAAiB,CAAC;AAEhE;;;;GAIG;AACU,QAAA,uCAAuC,GAClD,kCAA2C,CAAC;AAE9C;;;;GAIG;AACU,QAAA,gCAAgC,GAC3C,2BAAoC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The JSON-serialized value of each item in the `AttributeDefinitions` request field.\n *\n * @example [\"{ \"AttributeName\": \"string\", \"AttributeType\": \"string\" }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS =\n 'aws.dynamodb.attribute_definitions' as const;\n\n/**\n * The value of the `ConsistentRead` request parameter.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_CONSISTENT_READ =\n 'aws.dynamodb.consistent_read' as const;\n\n/**\n * The JSON-serialized value of each item in the `ConsumedCapacity` response field.\n *\n * @example [\"{ \"CapacityUnits\": number, \"GlobalSecondaryIndexes\": { \"string\" : { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }, \"LocalSecondaryIndexes\": { \"string\" : { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }, \"ReadCapacityUnits\": number, \"Table\": { \"CapacityUnits\": number, \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number }, \"TableName\": \"string\", \"WriteCapacityUnits\": number }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_CONSUMED_CAPACITY =\n 'aws.dynamodb.consumed_capacity' as const;\n\n/**\n * The value of the `Count` response parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_COUNT = 'aws.dynamodb.count' as const;\n\n/**\n * The value of the `ExclusiveStartTableName` request parameter.\n *\n * @example Users\n * @example CatsTable\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_EXCLUSIVE_START_TABLE =\n 'aws.dynamodb.exclusive_start_table' as const;\n\n/**\n * The JSON-serialized value of each item of the `GlobalSecondaryIndexes` request field\n *\n * @example [\"{ \"IndexName\": \"string\", \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" }, \"ProvisionedThroughput\": { \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES =\n 'aws.dynamodb.global_secondary_indexes' as const;\n\n/**\n * The JSON-serialized value of each item in the `GlobalSecondaryIndexUpdates` request field.\n *\n * @example [\"{ \"Create\": { \"IndexName\": \"string\", \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" }, \"ProvisionedThroughput\": { \"ReadCapacityUnits\": number, \"WriteCapacityUnits\": number } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES =\n 'aws.dynamodb.global_secondary_index_updates' as const;\n\n/**\n * The value of the `IndexName` request parameter.\n *\n * @example name_to_group\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_INDEX_NAME = 'aws.dynamodb.index_name' as const;\n\n/**\n * The JSON-serialized value of the `ItemCollectionMetrics` response field.\n *\n * @example { \"string\" : [ { \"ItemCollectionKey\": { \"string\" : { \"B\": blob, \"BOOL\": boolean, \"BS\": [ blob ], \"L\": [ \"AttributeValue\" ], \"M\": { \"string\" : \"AttributeValue\" }, \"N\": \"string\", \"NS\": [ \"string\" ], \"NULL\": boolean, \"S\": \"string\", \"SS\": [ \"string\" ] } }, \"SizeEstimateRangeGB\": [ number ] } ] }\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_ITEM_COLLECTION_METRICS =\n 'aws.dynamodb.item_collection_metrics' as const;\n\n/**\n * The value of the `Limit` request parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_LIMIT = 'aws.dynamodb.limit' as const;\n\n/**\n * The JSON-serialized value of each item of the `LocalSecondaryIndexes` request field.\n *\n * @example [\"{ \"IndexArn\": \"string\", \"IndexName\": \"string\", \"IndexSizeBytes\": number, \"ItemCount\": number, \"KeySchema\": [ { \"AttributeName\": \"string\", \"KeyType\": \"string\" } ], \"Projection\": { \"NonKeyAttributes\": [ \"string\" ], \"ProjectionType\": \"string\" } }\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES =\n 'aws.dynamodb.local_secondary_indexes' as const;\n\n/**\n * The value of the `ProjectionExpression` request parameter.\n *\n * @example Title\n * @example Title, Price, Color\n * @example Title, Description, RelatedItems, ProductReviews\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROJECTION = 'aws.dynamodb.projection' as const;\n\n/**\n * The value of the `ProvisionedThroughput.ReadCapacityUnits` request parameter.\n *\n * @example 1.0\n * @example 2.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROVISIONED_READ_CAPACITY =\n 'aws.dynamodb.provisioned_read_capacity' as const;\n\n/**\n * The value of the `ProvisionedThroughput.WriteCapacityUnits` request parameter.\n *\n * @example 1.0\n * @example 2.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY =\n 'aws.dynamodb.provisioned_write_capacity' as const;\n\n/**\n * The value of the `ScannedCount` response parameter.\n *\n * @example 50\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SCANNED_COUNT =\n 'aws.dynamodb.scanned_count' as const;\n\n/**\n * The value of the `ScanIndexForward` request parameter.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SCAN_FORWARD =\n 'aws.dynamodb.scan_forward' as const;\n\n/**\n * The value of the `Segment` request parameter.\n *\n * @example 10\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SEGMENT = 'aws.dynamodb.segment' as const;\n\n/**\n * The value of the `Select` request parameter.\n *\n * @example ALL_ATTRIBUTES\n * @example COUNT\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_SELECT = 'aws.dynamodb.select' as const;\n\n/**\n * The number of items in the `TableNames` response parameter.\n *\n * @example 20\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TABLE_COUNT =\n 'aws.dynamodb.table_count' as const;\n\n/**\n * The keys in the `RequestItems` object field.\n *\n * @example [\"Users\", \"Cats\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TABLE_NAMES =\n 'aws.dynamodb.table_names' as const;\n\n/**\n * The value of the `TotalSegments` request parameter.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_DYNAMODB_TOTAL_SEGMENTS =\n 'aws.dynamodb.total_segments' as const;\n\n/**\n * The ARN of the Secret stored in the Secrets Mangger\n *\n * @example arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretName-6RandomCharacters\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SECRETSMANAGER_SECRET_ARN =\n 'aws.secretsmanager.secret.arn' as const;\n\n/**\n * The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.\n *\n * @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions Activity.\n *\n * @example arn:aws:states:us-east-1:123456789012:activity:get-greeting\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN =\n 'aws.step_functions.activity.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions State Machine.\n *\n * @example arn:aws:states:us-east-1:123456789012:stateMachine:myStateMachine:1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN =\n 'aws.step_functions.state_machine.arn' as const;\n\n/**\n * Deprecated, use `db.namespace` instead.\n *\n * @example customers\n * @example main\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.namespace`.\n */\nexport const ATTR_DB_NAME = 'db.name' as const;\n\n/**\n * Deprecated, use `db.operation.name` instead.\n *\n * @example findAndModify\n * @example HMSET\n * @example SELECT\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.operation.name`.\n */\nexport const ATTR_DB_OPERATION = 'db.operation' as const;\n\n/**\n * The database statement being executed.\n *\n * @example SELECT * FROM wuser_table\n * @example SET mykey \"WuValue\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.query.text`.\n */\nexport const ATTR_DB_STATEMENT = 'db.statement' as const;\n\n/**\n * Deprecated, use `db.system.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `db.system.name`.\n */\nexport const ATTR_DB_SYSTEM = 'db.system' as const;\n\n/**\n * The name of the invoked function.\n *\n * @example \"my-function\"\n *\n * @note **SHOULD** be equal to the `faas.name` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_NAME = 'faas.invoked_name' as const;\n\n/**\n * The cloud provider of the invoked function.\n *\n * @note **SHOULD** be equal to the `cloud.provider` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_PROVIDER = 'faas.invoked_provider' as const;\n\n/**\n * The cloud region of the invoked function.\n *\n * @example \"eu-central-1\"\n *\n * @note **SHOULD** be equal to the `cloud.region` resource attribute of the invoked function.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_FAAS_INVOKED_REGION = 'faas.invoked_region' as const;\n\n/**\n * The name of the operation being performed.\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const;\n\n/**\n * The maximum number of tokens the model generates for a request.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MAX_TOKENS =\n 'gen_ai.request.max_tokens' as const;\n\n/**\n * The name of the GenAI model a request is being made to.\n *\n * @example \"gpt-4\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;\n\n/**\n * List of sequences that the model will use to stop generating further tokens.\n *\n * @example [\"forest\", \"lived\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES =\n 'gen_ai.request.stop_sequences' as const;\n\n/**\n * The temperature setting for the GenAI request.\n *\n * @example 0.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TEMPERATURE =\n 'gen_ai.request.temperature' as const;\n\n/**\n * The top_p sampling setting for the GenAI request.\n *\n * @example 1.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const;\n\n/**\n * Array of reasons the model stopped generating tokens, corresponding to each generation received.\n *\n * @example [\"stop\"]\n * @example [\"stop\", \"length\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_RESPONSE_FINISH_REASONS =\n 'gen_ai.response.finish_reasons' as const;\n\n/**\n * Deprecated, use `gen_ai.provider.name` instead.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `gen_ai.provider.name`.\n */\nexport const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;\n\n/**\n * The type of token being counted.\n *\n * @example input\n * @example output\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_TOKEN_TYPE = 'gen_ai.token.type' as const;\n\n/**\n * The number of tokens used in the GenAI input (prompt).\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_INPUT_TOKENS =\n 'gen_ai.usage.input_tokens' as const;\n\n/**\n * The number of tokens used in the GenAI response (completion).\n *\n * @example 180\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS =\n 'gen_ai.usage.output_tokens' as const;\n\n/**\n * Deprecated, use `http.response.status_code` instead.\n *\n * @example 200\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.status_code`.\n */\nexport const ATTR_HTTP_STATUS_CODE = 'http.status_code' as const;\n\n/**\n * The number of messages sent, received, or processed in the scope of the batching operation.\n *\n * @example 0\n * @example 1\n * @example 2\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_BATCH_MESSAGE_COUNT =\n 'messaging.batch.message_count' as const;\n\n/**\n * The message destination name\n *\n * @example MyQueue\n * @example MyTopic\n *\n * @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If\n * the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_DESTINATION_NAME =\n 'messaging.destination.name' as const;\n\n/**\n * A value used by the messaging system as an identifier for the message, represented as a string.\n *\n * @example \"452a7c7c7c7048c2f887f61572b18fc2\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;\n\n/**\n * Deprecated, use `messaging.operation.type` instead.\n *\n * @example publish\n * @example create\n * @example process\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `messaging.operation.type`.\n */\nexport const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const;\n\n/**\n * A string identifying the type of the messaging operation.\n *\n * @note If a custom value is used, it **MUST** be of low cardinality.\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_OPERATION_TYPE =\n 'messaging.operation.type' as const;\n\n/**\n * The messaging system as identified by the client instrumentation.\n *\n * @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.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;\n\n/**\n * The name of the (logical) method being called, must be equal to the $method part in the span name.\n *\n * @example \"exampleMethod\"\n *\n * @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).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_METHOD = 'rpc.method' as const;\n\n/**\n * The full (logical) name of the service being called, including its package name, if applicable.\n *\n * @example \"myservice.EchoService\"\n *\n * @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).\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_SERVICE = 'rpc.service' as const;\n\n/**\n * A string identifying the remoting system. See below for a list of well-known identifiers.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_SYSTEM = 'rpc.system' as const;\n\n/**\n * Enum value \"dynamodb\" for attribute {@link ATTR_DB_SYSTEM}.\n *\n * Amazon DynamoDB\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const DB_SYSTEM_VALUE_DYNAMODB = 'dynamodb' as const;\n\n/**\n * Enum value \"chat\" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.\n *\n * Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat' as const;\n\n/**\n * Enum value \"aws.bedrock\" for attribute {@link ATTR_GEN_AI_SYSTEM}.\n *\n * AWS Bedrock\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock' as const;\n\n/**\n * Enum value \"input\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Input tokens (prompt, input, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;\n\n/**\n * Enum value \"output\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Output tokens (completion, response, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;\n\n/**\n * GenAI operation duration.\n *\n * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const METRIC_GEN_AI_CLIENT_OPERATION_DURATION =\n 'gen_ai.client.operation.duration' as const;\n\n/**\n * Number of input and output tokens used.\n *\n * @experimental This metric is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const METRIC_GEN_AI_CLIENT_TOKEN_USAGE =\n 'gen_ai.client.token.usage' as const;\n"]}
@@ -4,6 +4,7 @@ import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } fr
4
4
  export declare class BedrockRuntimeServiceExtension implements ServiceExtension {
5
5
  private tokenUsage;
6
6
  private operationDuration;
7
+ private _diag;
7
8
  updateMetricInstruments(meter: Meter): void;
8
9
  requestPreSpanHook(request: NormalizedRequest, config: AwsSdkInstrumentationConfig, diag: DiagLogger): RequestMetadata;
9
10
  private requestPreSpanHookConverse;
@@ -15,5 +16,14 @@ export declare class BedrockRuntimeServiceExtension implements ServiceExtension
15
16
  private static setStopReason;
16
17
  private setUsage;
17
18
  private responseHookInvokeModel;
19
+ private responseHookInvokeModelWithResponseStream;
20
+ private parseChunk;
21
+ private static recordNovaAttributes;
22
+ private static recordClaudeAttributes;
23
+ private static recordTitanAttributes;
24
+ private static recordLlamaAttributes;
25
+ private static recordMistralAttributes;
26
+ private static recordCohereAttributes;
27
+ private static recordCohereRAttributes;
18
28
  }
19
29
  //# sourceMappingURL=bedrock-runtime.d.ts.map
@@ -22,9 +22,10 @@ const core_1 = require("@opentelemetry/core");
22
22
  class BedrockRuntimeServiceExtension {
23
23
  tokenUsage;
24
24
  operationDuration;
25
+ _diag = api_1.diag;
25
26
  updateMetricInstruments(meter) {
26
27
  // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclienttokenusage
27
- this.tokenUsage = meter.createHistogram('gen_ai.client.token.usage', {
28
+ this.tokenUsage = meter.createHistogram(semconv_1.METRIC_GEN_AI_CLIENT_TOKEN_USAGE, {
28
29
  unit: '{token}',
29
30
  description: 'Measures number of input and output tokens used',
30
31
  valueType: api_1.ValueType.INT,
@@ -36,7 +37,7 @@ class BedrockRuntimeServiceExtension {
36
37
  },
37
38
  });
38
39
  // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclientoperationduration
39
- this.operationDuration = meter.createHistogram('gen_ai.client.operation.duration', {
40
+ this.operationDuration = meter.createHistogram(semconv_1.METRIC_GEN_AI_CLIENT_OPERATION_DURATION, {
40
41
  unit: 's',
41
42
  description: 'GenAI operation duration',
42
43
  advice: {
@@ -54,7 +55,9 @@ class BedrockRuntimeServiceExtension {
54
55
  case 'ConverseStream':
55
56
  return this.requestPreSpanHookConverse(request, config, diag, true);
56
57
  case 'InvokeModel':
57
- return this.requestPreSpanHookInvokeModel(request, config, diag);
58
+ return this.requestPreSpanHookInvokeModel(request, config, diag, false);
59
+ case 'InvokeModelWithResponseStream':
60
+ return this.requestPreSpanHookInvokeModel(request, config, diag, true);
58
61
  }
59
62
  return {
60
63
  isIncoming: false,
@@ -96,7 +99,7 @@ class BedrockRuntimeServiceExtension {
96
99
  spanAttributes,
97
100
  };
98
101
  }
99
- requestPreSpanHookInvokeModel(request, config, diag) {
102
+ requestPreSpanHookInvokeModel(request, config, diag, isStream) {
100
103
  let spanName;
101
104
  const spanAttributes = {
102
105
  [semconv_1.ATTR_GEN_AI_SYSTEM]: semconv_1.GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,
@@ -247,6 +250,7 @@ class BedrockRuntimeServiceExtension {
247
250
  return {
248
251
  spanName,
249
252
  isIncoming: false,
253
+ isStream,
250
254
  spanAttributes,
251
255
  };
252
256
  }
@@ -261,6 +265,8 @@ class BedrockRuntimeServiceExtension {
261
265
  return this.responseHookConverseStream(response, span, tracer, config, startTime);
262
266
  case 'InvokeModel':
263
267
  return this.responseHookInvokeModel(response, span, tracer, config);
268
+ case 'InvokeModelWithResponseStream':
269
+ return this.responseHookInvokeModelWithResponseStream(response, span, tracer, config);
264
270
  }
265
271
  }
266
272
  responseHookConverse(response, span, tracer, config, startTime) {
@@ -423,6 +429,159 @@ class BedrockRuntimeServiceExtension {
423
429
  }
424
430
  }
425
431
  }
432
+ async responseHookInvokeModelWithResponseStream(response, span, tracer, config) {
433
+ const stream = response.data?.body;
434
+ const modelId = response.request.commandInput?.modelId;
435
+ if (!stream || !modelId)
436
+ return;
437
+ // Replace the original response body with our instrumented stream.
438
+ // - Defers span.end() until the entire stream is consumed
439
+ // This ensures downstream consumers still receive the full stream correctly,
440
+ // while OpenTelemetry can record span attributes from streamed data.
441
+ response.data.body = async function* () {
442
+ try {
443
+ for await (const chunk of stream) {
444
+ const parsedChunk = this.parseChunk(chunk?.chunk?.bytes);
445
+ if (!parsedChunk) {
446
+ // pass through
447
+ }
448
+ else if (modelId.includes('amazon.titan')) {
449
+ BedrockRuntimeServiceExtension.recordTitanAttributes(parsedChunk, span);
450
+ }
451
+ else if (modelId.includes('anthropic.claude')) {
452
+ BedrockRuntimeServiceExtension.recordClaudeAttributes(parsedChunk, span);
453
+ }
454
+ else if (modelId.includes('amazon.nova')) {
455
+ BedrockRuntimeServiceExtension.recordNovaAttributes(parsedChunk, span);
456
+ }
457
+ else if (modelId.includes('meta.llama')) {
458
+ BedrockRuntimeServiceExtension.recordLlamaAttributes(parsedChunk, span);
459
+ }
460
+ else if (modelId.includes('cohere.command-r')) {
461
+ BedrockRuntimeServiceExtension.recordCohereRAttributes(parsedChunk, span);
462
+ }
463
+ else if (modelId.includes('cohere.command')) {
464
+ BedrockRuntimeServiceExtension.recordCohereAttributes(parsedChunk, span);
465
+ }
466
+ else if (modelId.includes('mistral')) {
467
+ BedrockRuntimeServiceExtension.recordMistralAttributes(parsedChunk, span);
468
+ }
469
+ yield chunk;
470
+ }
471
+ }
472
+ finally {
473
+ span.end();
474
+ }
475
+ }.bind(this)();
476
+ return response.data;
477
+ }
478
+ parseChunk(bytes) {
479
+ if (!bytes || !(bytes instanceof Uint8Array))
480
+ return null;
481
+ try {
482
+ const str = Buffer.from(bytes).toString('utf-8');
483
+ return JSON.parse(str);
484
+ }
485
+ catch (err) {
486
+ this._diag.warn('Failed to parse streamed chunk', err);
487
+ return null;
488
+ }
489
+ }
490
+ static recordNovaAttributes(parsedChunk, span) {
491
+ if (parsedChunk.metadata?.usage !== undefined) {
492
+ if (parsedChunk.metadata?.usage.inputTokens !== undefined) {
493
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_INPUT_TOKENS, parsedChunk.metadata.usage.inputTokens);
494
+ }
495
+ if (parsedChunk.metadata?.usage.outputTokens !== undefined) {
496
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, parsedChunk.metadata.usage.outputTokens);
497
+ }
498
+ }
499
+ if (parsedChunk.messageStop?.stopReason !== undefined) {
500
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
501
+ parsedChunk.messageStop.stopReason,
502
+ ]);
503
+ }
504
+ }
505
+ static recordClaudeAttributes(parsedChunk, span) {
506
+ if (parsedChunk.message?.usage?.input_tokens !== undefined) {
507
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_INPUT_TOKENS, parsedChunk.message.usage.input_tokens);
508
+ }
509
+ if (parsedChunk.message?.usage?.output_tokens !== undefined) {
510
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, parsedChunk.message.usage.output_tokens);
511
+ }
512
+ if (parsedChunk.delta?.stop_reason !== undefined) {
513
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
514
+ parsedChunk.delta.stop_reason,
515
+ ]);
516
+ }
517
+ }
518
+ static recordTitanAttributes(parsedChunk, span) {
519
+ if (parsedChunk.inputTextTokenCount !== undefined) {
520
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_INPUT_TOKENS, parsedChunk.inputTextTokenCount);
521
+ }
522
+ if (parsedChunk.totalOutputTextTokenCount !== undefined) {
523
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, parsedChunk.totalOutputTextTokenCount);
524
+ }
525
+ if (parsedChunk.completionReason !== undefined) {
526
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
527
+ parsedChunk.completionReason,
528
+ ]);
529
+ }
530
+ }
531
+ static recordLlamaAttributes(parsedChunk, span) {
532
+ if (parsedChunk.prompt_token_count !== undefined) {
533
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_INPUT_TOKENS, parsedChunk.prompt_token_count);
534
+ }
535
+ if (parsedChunk.generation_token_count !== undefined) {
536
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, parsedChunk.generation_token_count);
537
+ }
538
+ if (parsedChunk.stop_reason !== undefined) {
539
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
540
+ parsedChunk.stop_reason,
541
+ ]);
542
+ }
543
+ }
544
+ static recordMistralAttributes(parsedChunk, span) {
545
+ if (parsedChunk.outputs?.[0]?.text !== undefined) {
546
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,
547
+ // NOTE: We approximate the token count since this value is not directly available in the body
548
+ // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.
549
+ // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html
550
+ Math.ceil(parsedChunk.outputs[0].text.length / 6));
551
+ }
552
+ if (parsedChunk.outputs?.[0]?.stop_reason !== undefined) {
553
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
554
+ parsedChunk.outputs[0].stop_reason,
555
+ ]);
556
+ }
557
+ }
558
+ static recordCohereAttributes(parsedChunk, span) {
559
+ if (parsedChunk.generations?.[0]?.text !== undefined) {
560
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,
561
+ // NOTE: We approximate the token count since this value is not directly available in the body
562
+ // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.
563
+ // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html
564
+ Math.ceil(parsedChunk.generations[0].text.length / 6));
565
+ }
566
+ if (parsedChunk.generations?.[0]?.finish_reason !== undefined) {
567
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
568
+ parsedChunk.generations[0].finish_reason,
569
+ ]);
570
+ }
571
+ }
572
+ static recordCohereRAttributes(parsedChunk, span) {
573
+ if (parsedChunk.text !== undefined) {
574
+ // NOTE: We approximate the token count since this value is not directly available in the body
575
+ // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.
576
+ // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html
577
+ span.setAttribute(semconv_1.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, Math.ceil(parsedChunk.text.length / 6));
578
+ }
579
+ if (parsedChunk.finish_reason !== undefined) {
580
+ span.setAttribute(semconv_1.ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [
581
+ parsedChunk.finish_reason,
582
+ ]);
583
+ }
584
+ }
426
585
  }
427
586
  exports.BedrockRuntimeServiceExtension = BedrockRuntimeServiceExtension;
428
587
  //# sourceMappingURL=bedrock-runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bedrock-runtime.js","sourceRoot":"","sources":["../../../src/services/bedrock-runtime.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAS4B;AAE5B,wCAg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authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Attributes,\n DiagLogger,\n Histogram,\n HrTime,\n Meter,\n Span,\n Tracer,\n ValueType,\n} from '@opentelemetry/api';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport {\n ATTR_GEN_AI_SYSTEM,\n ATTR_GEN_AI_OPERATION_NAME,\n ATTR_GEN_AI_REQUEST_MODEL,\n ATTR_GEN_AI_REQUEST_MAX_TOKENS,\n ATTR_GEN_AI_REQUEST_TEMPERATURE,\n ATTR_GEN_AI_REQUEST_TOP_P,\n ATTR_GEN_AI_REQUEST_STOP_SEQUENCES,\n ATTR_GEN_AI_TOKEN_TYPE,\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n ATTR_GEN_AI_RESPONSE_FINISH_REASONS,\n GEN_AI_OPERATION_NAME_VALUE_CHAT,\n GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n GEN_AI_TOKEN_TYPE_VALUE_INPUT,\n GEN_AI_TOKEN_TYPE_VALUE_OUTPUT,\n} from '../semconv';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport type {\n ConverseStreamOutput,\n TokenUsage,\n} from '@aws-sdk/client-bedrock-runtime';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n} from '@opentelemetry/core';\n\nexport class BedrockRuntimeServiceExtension implements ServiceExtension {\n private tokenUsage!: Histogram;\n private operationDuration!: Histogram;\n\n updateMetricInstruments(meter: Meter) {\n // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclienttokenusage\n this.tokenUsage = meter.createHistogram('gen_ai.client.token.usage', {\n unit: '{token}',\n description: 'Measures number of input and output tokens used',\n valueType: ValueType.INT,\n advice: {\n explicitBucketBoundaries: [\n 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304,\n 16777216, 67108864,\n ],\n },\n });\n\n // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclientoperationduration\n this.operationDuration = meter.createHistogram(\n 'gen_ai.client.operation.duration',\n {\n unit: 's',\n description: 'GenAI operation duration',\n advice: {\n explicitBucketBoundaries: [\n 0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24,\n 20.48, 40.96, 81.92,\n ],\n },\n }\n );\n }\n\n requestPreSpanHook(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n switch (request.commandName) {\n case 'Converse':\n return this.requestPreSpanHookConverse(request, config, diag, false);\n case 'ConverseStream':\n return this.requestPreSpanHookConverse(request, config, diag, true);\n case 'InvokeModel':\n return this.requestPreSpanHookInvokeModel(request, config, diag);\n }\n\n return {\n isIncoming: false,\n };\n }\n\n private requestPreSpanHookConverse(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger,\n isStream: boolean\n ): RequestMetadata {\n let spanName = GEN_AI_OPERATION_NAME_VALUE_CHAT;\n const spanAttributes: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n [ATTR_GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_CHAT,\n };\n\n const modelId = request.commandInput.modelId;\n if (modelId) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MODEL] = modelId;\n if (spanName) {\n spanName += ` ${modelId}`;\n }\n }\n\n const inferenceConfig = request.commandInput.inferenceConfig;\n if (inferenceConfig) {\n const { maxTokens, temperature, topP, stopSequences } = inferenceConfig;\n if (maxTokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] = maxTokens;\n }\n if (temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] = temperature;\n }\n if (topP !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = topP;\n }\n if (stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] = stopSequences;\n }\n }\n\n return {\n spanName,\n isIncoming: false,\n isStream,\n spanAttributes,\n };\n }\n\n private requestPreSpanHookInvokeModel(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n let spanName: string | undefined;\n const spanAttributes: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n // add operation name for InvokeModel API\n };\n\n const modelId = request.commandInput?.modelId;\n if (modelId) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MODEL] = modelId;\n }\n\n if (request.commandInput?.body) {\n const requestBody = JSON.parse(request.commandInput.body);\n if (modelId.includes('amazon.titan')) {\n if (requestBody.textGenerationConfig?.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.textGenerationConfig.temperature;\n }\n if (requestBody.textGenerationConfig?.topP !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] =\n requestBody.textGenerationConfig.topP;\n }\n if (requestBody.textGenerationConfig?.maxTokenCount !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.textGenerationConfig.maxTokenCount;\n }\n if (requestBody.textGenerationConfig?.stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.textGenerationConfig.stopSequences;\n }\n } else if (modelId.includes('amazon.nova')) {\n if (requestBody.inferenceConfig?.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.inferenceConfig.temperature;\n }\n if (requestBody.inferenceConfig?.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] =\n requestBody.inferenceConfig.top_p;\n }\n if (requestBody.inferenceConfig?.max_new_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.inferenceConfig.max_new_tokens;\n }\n if (requestBody.inferenceConfig?.stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.inferenceConfig.stopSequences;\n }\n } else if (modelId.includes('anthropic.claude')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('meta.llama')) {\n if (requestBody.max_gen_len !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_gen_len;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n // request for meta llama models does not contain stop_sequences field\n } else if (modelId.includes('cohere.command-r')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.p;\n }\n if (requestBody.message !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.message.length / 6\n );\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('cohere.command')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.p;\n }\n if (requestBody.prompt !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.prompt.length / 6\n );\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('mistral')) {\n if (requestBody.prompt !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.prompt.length / 6\n );\n }\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n if (requestBody.stop !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] = requestBody.stop;\n }\n }\n }\n\n return {\n spanName,\n isIncoming: false,\n spanAttributes,\n };\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n if (!span.isRecording()) {\n return;\n }\n\n switch (response.request.commandName) {\n case 'Converse':\n return this.responseHookConverse(\n response,\n span,\n tracer,\n config,\n startTime\n );\n case 'ConverseStream':\n return this.responseHookConverseStream(\n response,\n span,\n tracer,\n config,\n startTime\n );\n case 'InvokeModel':\n return this.responseHookInvokeModel(response, span, tracer, config);\n }\n }\n\n private responseHookConverse(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n const { stopReason, usage } = response.data;\n\n BedrockRuntimeServiceExtension.setStopReason(span, stopReason);\n this.setUsage(response, span, usage, startTime);\n }\n\n private responseHookConverseStream(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n return {\n ...response.data,\n // Wrap and replace the response stream to allow processing events to telemetry\n // before yielding to the user.\n stream: this.wrapConverseStreamResponse(\n response,\n response.data.stream,\n span,\n startTime\n ),\n };\n }\n\n private async *wrapConverseStreamResponse(\n response: NormalizedResponse,\n stream: AsyncIterable<ConverseStreamOutput>,\n span: Span,\n startTime: HrTime\n ) {\n try {\n let usage: TokenUsage | undefined;\n for await (const item of stream) {\n BedrockRuntimeServiceExtension.setStopReason(\n span,\n item.messageStop?.stopReason\n );\n usage = item.metadata?.usage;\n yield item;\n }\n this.setUsage(response, span, usage, startTime);\n } finally {\n span.end();\n }\n }\n\n private static setStopReason(span: Span, stopReason: string | undefined) {\n if (stopReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [stopReason]);\n }\n }\n\n private setUsage(\n response: NormalizedResponse,\n span: Span,\n usage: TokenUsage | undefined,\n startTime: HrTime\n ) {\n const sharedMetricAttrs: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n [ATTR_GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_CHAT,\n [ATTR_GEN_AI_REQUEST_MODEL]: response.request.commandInput.modelId,\n };\n\n const durationSecs =\n hrTimeToMilliseconds(hrTimeDuration(startTime, hrTime())) / 1000;\n this.operationDuration.record(durationSecs, sharedMetricAttrs);\n\n if (usage) {\n const { inputTokens, outputTokens } = usage;\n if (inputTokens !== undefined) {\n span.setAttribute(ATTR_GEN_AI_USAGE_INPUT_TOKENS, inputTokens);\n\n this.tokenUsage.record(inputTokens, {\n ...sharedMetricAttrs,\n [ATTR_GEN_AI_TOKEN_TYPE]: GEN_AI_TOKEN_TYPE_VALUE_INPUT,\n });\n }\n if (outputTokens !== undefined) {\n span.setAttribute(ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);\n\n this.tokenUsage.record(outputTokens, {\n ...sharedMetricAttrs,\n [ATTR_GEN_AI_TOKEN_TYPE]: GEN_AI_TOKEN_TYPE_VALUE_OUTPUT,\n });\n }\n }\n }\n\n private responseHookInvokeModel(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) {\n const currentModelId = response.request.commandInput?.modelId;\n if (response.data?.body) {\n const decodedResponseBody = new TextDecoder().decode(response.data.body);\n const responseBody = JSON.parse(decodedResponseBody);\n if (currentModelId.includes('amazon.titan')) {\n if (responseBody.inputTextTokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.inputTextTokenCount\n );\n }\n if (responseBody.results?.[0]?.tokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.results[0].tokenCount\n );\n }\n if (responseBody.results?.[0]?.completionReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.results[0].completionReason,\n ]);\n }\n } else if (currentModelId.includes('amazon.nova')) {\n if (responseBody.usage !== undefined) {\n if (responseBody.usage.inputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.usage.inputTokens\n );\n }\n if (responseBody.usage.outputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.usage.outputTokens\n );\n }\n }\n if (responseBody.stopReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stopReason,\n ]);\n }\n } else if (currentModelId.includes('anthropic.claude')) {\n if (responseBody.usage?.input_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.usage.input_tokens\n );\n }\n if (responseBody.usage?.output_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.usage.output_tokens\n );\n }\n if (responseBody.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stop_reason,\n ]);\n }\n } else if (currentModelId.includes('meta.llama')) {\n if (responseBody.prompt_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.prompt_token_count\n );\n }\n if (responseBody.generation_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.generation_token_count\n );\n }\n if (responseBody.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stop_reason,\n ]);\n }\n } else if (currentModelId.includes('cohere.command-r')) {\n if (responseBody.text !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n Math.ceil(responseBody.text.length / 6)\n );\n }\n if (responseBody.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.finish_reason,\n ]);\n }\n } else if (currentModelId.includes('cohere.command')) {\n if (responseBody.generations?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(responseBody.generations[0].text.length / 6)\n );\n }\n if (responseBody.generations?.[0]?.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.generations[0].finish_reason,\n ]);\n }\n } else if (currentModelId.includes('mistral')) {\n if (responseBody.outputs?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(responseBody.outputs[0].text.length / 6)\n );\n }\n if (responseBody.outputs?.[0]?.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.outputs[0].stop_reason,\n ]);\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"bedrock-runtime.js","sourceRoot":"","sources":["../../../src/services/bedrock-runtime.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAU4B;AAE5B,wCAkBoB;AAUpB,8CAI6B;AAE7B,MAAa,8BAA8B;IACjC,UAAU,CAAa;IACvB,iBAAiB,CAAa;IAC9B,KAAK,GAAe,UAAI,CAAC;IAEjC,uBAAuB,CAAC,KAAY;QAClC,mGAAmG;QACnG,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,eAAe,CAAC,0CAAgC,EAAE;YACxE,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,iDAAiD;YAC9D,SAAS,EAAE,eAAS,CAAC,GAAG;YACxB,MAAM,EAAE;gBACN,wBAAwB,EAAE;oBACxB,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;oBACrE,QAAQ,EAAE,QAAQ;iBACnB;aACF;SACF,CAAC,CAAC;QAEH,0GAA0G;QAC1G,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,eAAe,CAC5C,iDAAuC,EACvC;YACE,IAAI,EAAE,GAAG;YACT,WAAW,EAAE,0BAA0B;YACvC,MAAM,EAAE;gBACN,wBAAwB,EAAE;oBACxB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;oBACjE,KAAK,EAAE,KAAK,EAAE,KAAK;iBACpB;aACF;SACF,CACF,CAAC;IACJ,CAAC;IAED,kBAAkB,CAChB,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AI,CAAC,MAAM,GAAG,CAAC,CAAC,CACvC,CAAC;SACH;QACD,IAAI,WAAW,CAAC,aAAa,KAAK,SAAS,EAAE;YAC3C,IAAI,CAAC,YAAY,CAAC,6CAAmC,EAAE;gBACrD,WAAW,CAAC,aAAa;aAC1B,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AA1uBD,wEA0uBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Attributes,\n DiagLogger,\n diag,\n Histogram,\n HrTime,\n Meter,\n Span,\n Tracer,\n ValueType,\n} from '@opentelemetry/api';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport {\n ATTR_GEN_AI_SYSTEM,\n ATTR_GEN_AI_OPERATION_NAME,\n ATTR_GEN_AI_REQUEST_MODEL,\n ATTR_GEN_AI_REQUEST_MAX_TOKENS,\n ATTR_GEN_AI_REQUEST_TEMPERATURE,\n ATTR_GEN_AI_REQUEST_TOP_P,\n ATTR_GEN_AI_REQUEST_STOP_SEQUENCES,\n ATTR_GEN_AI_TOKEN_TYPE,\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n ATTR_GEN_AI_RESPONSE_FINISH_REASONS,\n GEN_AI_OPERATION_NAME_VALUE_CHAT,\n GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n GEN_AI_TOKEN_TYPE_VALUE_INPUT,\n GEN_AI_TOKEN_TYPE_VALUE_OUTPUT,\n METRIC_GEN_AI_CLIENT_OPERATION_DURATION,\n METRIC_GEN_AI_CLIENT_TOKEN_USAGE,\n} from '../semconv';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport type {\n ConverseStreamOutput,\n TokenUsage,\n} from '@aws-sdk/client-bedrock-runtime';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n} from '@opentelemetry/core';\n\nexport class BedrockRuntimeServiceExtension implements ServiceExtension {\n private tokenUsage!: Histogram;\n private operationDuration!: Histogram;\n private _diag: DiagLogger = diag;\n\n updateMetricInstruments(meter: Meter) {\n // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclienttokenusage\n this.tokenUsage = meter.createHistogram(METRIC_GEN_AI_CLIENT_TOKEN_USAGE, {\n unit: '{token}',\n description: 'Measures number of input and output tokens used',\n valueType: ValueType.INT,\n advice: {\n explicitBucketBoundaries: [\n 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304,\n 16777216, 67108864,\n ],\n },\n });\n\n // https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-metrics/#metric-gen_aiclientoperationduration\n this.operationDuration = meter.createHistogram(\n METRIC_GEN_AI_CLIENT_OPERATION_DURATION,\n {\n unit: 's',\n description: 'GenAI operation duration',\n advice: {\n explicitBucketBoundaries: [\n 0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24,\n 20.48, 40.96, 81.92,\n ],\n },\n }\n );\n }\n\n requestPreSpanHook(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n switch (request.commandName) {\n case 'Converse':\n return this.requestPreSpanHookConverse(request, config, diag, false);\n case 'ConverseStream':\n return this.requestPreSpanHookConverse(request, config, diag, true);\n case 'InvokeModel':\n return this.requestPreSpanHookInvokeModel(request, config, diag, false);\n case 'InvokeModelWithResponseStream':\n return this.requestPreSpanHookInvokeModel(request, config, diag, true);\n }\n\n return {\n isIncoming: false,\n };\n }\n\n private requestPreSpanHookConverse(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger,\n isStream: boolean\n ): RequestMetadata {\n let spanName = GEN_AI_OPERATION_NAME_VALUE_CHAT;\n const spanAttributes: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n [ATTR_GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_CHAT,\n };\n\n const modelId = request.commandInput.modelId;\n if (modelId) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MODEL] = modelId;\n if (spanName) {\n spanName += ` ${modelId}`;\n }\n }\n\n const inferenceConfig = request.commandInput.inferenceConfig;\n if (inferenceConfig) {\n const { maxTokens, temperature, topP, stopSequences } = inferenceConfig;\n if (maxTokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] = maxTokens;\n }\n if (temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] = temperature;\n }\n if (topP !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = topP;\n }\n if (stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] = stopSequences;\n }\n }\n\n return {\n spanName,\n isIncoming: false,\n isStream,\n spanAttributes,\n };\n }\n\n private requestPreSpanHookInvokeModel(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger,\n isStream: boolean\n ): RequestMetadata {\n let spanName: string | undefined;\n const spanAttributes: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n // add operation name for InvokeModel API\n };\n\n const modelId = request.commandInput?.modelId;\n if (modelId) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MODEL] = modelId;\n }\n\n if (request.commandInput?.body) {\n const requestBody = JSON.parse(request.commandInput.body);\n if (modelId.includes('amazon.titan')) {\n if (requestBody.textGenerationConfig?.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.textGenerationConfig.temperature;\n }\n if (requestBody.textGenerationConfig?.topP !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] =\n requestBody.textGenerationConfig.topP;\n }\n if (requestBody.textGenerationConfig?.maxTokenCount !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.textGenerationConfig.maxTokenCount;\n }\n if (requestBody.textGenerationConfig?.stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.textGenerationConfig.stopSequences;\n }\n } else if (modelId.includes('amazon.nova')) {\n if (requestBody.inferenceConfig?.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.inferenceConfig.temperature;\n }\n if (requestBody.inferenceConfig?.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] =\n requestBody.inferenceConfig.top_p;\n }\n if (requestBody.inferenceConfig?.max_new_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.inferenceConfig.max_new_tokens;\n }\n if (requestBody.inferenceConfig?.stopSequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.inferenceConfig.stopSequences;\n }\n } else if (modelId.includes('anthropic.claude')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('meta.llama')) {\n if (requestBody.max_gen_len !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_gen_len;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n // request for meta llama models does not contain stop_sequences field\n } else if (modelId.includes('cohere.command-r')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.p;\n }\n if (requestBody.message !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.message.length / 6\n );\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('cohere.command')) {\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.p;\n }\n if (requestBody.prompt !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.prompt.length / 6\n );\n }\n if (requestBody.stop_sequences !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] =\n requestBody.stop_sequences;\n }\n } else if (modelId.includes('mistral')) {\n if (requestBody.prompt !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n spanAttributes[ATTR_GEN_AI_USAGE_INPUT_TOKENS] = Math.ceil(\n requestBody.prompt.length / 6\n );\n }\n if (requestBody.max_tokens !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_MAX_TOKENS] =\n requestBody.max_tokens;\n }\n if (requestBody.temperature !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TEMPERATURE] =\n requestBody.temperature;\n }\n if (requestBody.top_p !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_TOP_P] = requestBody.top_p;\n }\n if (requestBody.stop !== undefined) {\n spanAttributes[ATTR_GEN_AI_REQUEST_STOP_SEQUENCES] = requestBody.stop;\n }\n }\n }\n\n return {\n spanName,\n isIncoming: false,\n isStream,\n spanAttributes,\n };\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n if (!span.isRecording()) {\n return;\n }\n\n switch (response.request.commandName) {\n case 'Converse':\n return this.responseHookConverse(\n response,\n span,\n tracer,\n config,\n startTime\n );\n case 'ConverseStream':\n return this.responseHookConverseStream(\n response,\n span,\n tracer,\n config,\n startTime\n );\n case 'InvokeModel':\n return this.responseHookInvokeModel(response, span, tracer, config);\n case 'InvokeModelWithResponseStream':\n return this.responseHookInvokeModelWithResponseStream(\n response,\n span,\n tracer,\n config\n );\n }\n }\n\n private responseHookConverse(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n const { stopReason, usage } = response.data;\n\n BedrockRuntimeServiceExtension.setStopReason(span, stopReason);\n this.setUsage(response, span, usage, startTime);\n }\n\n private responseHookConverseStream(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n return {\n ...response.data,\n // Wrap and replace the response stream to allow processing events to telemetry\n // before yielding to the user.\n stream: this.wrapConverseStreamResponse(\n response,\n response.data.stream,\n span,\n startTime\n ),\n };\n }\n\n private async *wrapConverseStreamResponse(\n response: NormalizedResponse,\n stream: AsyncIterable<ConverseStreamOutput>,\n span: Span,\n startTime: HrTime\n ) {\n try {\n let usage: TokenUsage | undefined;\n for await (const item of stream) {\n BedrockRuntimeServiceExtension.setStopReason(\n span,\n item.messageStop?.stopReason\n );\n usage = item.metadata?.usage;\n yield item;\n }\n this.setUsage(response, span, usage, startTime);\n } finally {\n span.end();\n }\n }\n\n private static setStopReason(span: Span, stopReason: string | undefined) {\n if (stopReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [stopReason]);\n }\n }\n\n private setUsage(\n response: NormalizedResponse,\n span: Span,\n usage: TokenUsage | undefined,\n startTime: HrTime\n ) {\n const sharedMetricAttrs: Attributes = {\n [ATTR_GEN_AI_SYSTEM]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,\n [ATTR_GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_CHAT,\n [ATTR_GEN_AI_REQUEST_MODEL]: response.request.commandInput.modelId,\n };\n\n const durationSecs =\n hrTimeToMilliseconds(hrTimeDuration(startTime, hrTime())) / 1000;\n this.operationDuration.record(durationSecs, sharedMetricAttrs);\n\n if (usage) {\n const { inputTokens, outputTokens } = usage;\n if (inputTokens !== undefined) {\n span.setAttribute(ATTR_GEN_AI_USAGE_INPUT_TOKENS, inputTokens);\n\n this.tokenUsage.record(inputTokens, {\n ...sharedMetricAttrs,\n [ATTR_GEN_AI_TOKEN_TYPE]: GEN_AI_TOKEN_TYPE_VALUE_INPUT,\n });\n }\n if (outputTokens !== undefined) {\n span.setAttribute(ATTR_GEN_AI_USAGE_OUTPUT_TOKENS, outputTokens);\n\n this.tokenUsage.record(outputTokens, {\n ...sharedMetricAttrs,\n [ATTR_GEN_AI_TOKEN_TYPE]: GEN_AI_TOKEN_TYPE_VALUE_OUTPUT,\n });\n }\n }\n }\n\n private responseHookInvokeModel(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) {\n const currentModelId = response.request.commandInput?.modelId;\n if (response.data?.body) {\n const decodedResponseBody = new TextDecoder().decode(response.data.body);\n const responseBody = JSON.parse(decodedResponseBody);\n if (currentModelId.includes('amazon.titan')) {\n if (responseBody.inputTextTokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.inputTextTokenCount\n );\n }\n if (responseBody.results?.[0]?.tokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.results[0].tokenCount\n );\n }\n if (responseBody.results?.[0]?.completionReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.results[0].completionReason,\n ]);\n }\n } else if (currentModelId.includes('amazon.nova')) {\n if (responseBody.usage !== undefined) {\n if (responseBody.usage.inputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.usage.inputTokens\n );\n }\n if (responseBody.usage.outputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.usage.outputTokens\n );\n }\n }\n if (responseBody.stopReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stopReason,\n ]);\n }\n } else if (currentModelId.includes('anthropic.claude')) {\n if (responseBody.usage?.input_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.usage.input_tokens\n );\n }\n if (responseBody.usage?.output_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.usage.output_tokens\n );\n }\n if (responseBody.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stop_reason,\n ]);\n }\n } else if (currentModelId.includes('meta.llama')) {\n if (responseBody.prompt_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n responseBody.prompt_token_count\n );\n }\n if (responseBody.generation_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n responseBody.generation_token_count\n );\n }\n if (responseBody.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.stop_reason,\n ]);\n }\n } else if (currentModelId.includes('cohere.command-r')) {\n if (responseBody.text !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n Math.ceil(responseBody.text.length / 6)\n );\n }\n if (responseBody.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.finish_reason,\n ]);\n }\n } else if (currentModelId.includes('cohere.command')) {\n if (responseBody.generations?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(responseBody.generations[0].text.length / 6)\n );\n }\n if (responseBody.generations?.[0]?.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.generations[0].finish_reason,\n ]);\n }\n } else if (currentModelId.includes('mistral')) {\n if (responseBody.outputs?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(responseBody.outputs[0].text.length / 6)\n );\n }\n if (responseBody.outputs?.[0]?.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n responseBody.outputs[0].stop_reason,\n ]);\n }\n }\n }\n }\n\n private async responseHookInvokeModelWithResponseStream(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ): Promise<any> {\n const stream = response.data?.body;\n const modelId = response.request.commandInput?.modelId;\n if (!stream || !modelId) return;\n\n // Replace the original response body with our instrumented stream.\n // - Defers span.end() until the entire stream is consumed\n // This ensures downstream consumers still receive the full stream correctly,\n // while OpenTelemetry can record span attributes from streamed data.\n response.data.body = async function* (\n this: BedrockRuntimeServiceExtension\n ) {\n try {\n for await (const chunk of stream) {\n const parsedChunk = this.parseChunk(chunk?.chunk?.bytes);\n\n if (!parsedChunk) {\n // pass through\n } else if (modelId.includes('amazon.titan')) {\n BedrockRuntimeServiceExtension.recordTitanAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('anthropic.claude')) {\n BedrockRuntimeServiceExtension.recordClaudeAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('amazon.nova')) {\n BedrockRuntimeServiceExtension.recordNovaAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('meta.llama')) {\n BedrockRuntimeServiceExtension.recordLlamaAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('cohere.command-r')) {\n BedrockRuntimeServiceExtension.recordCohereRAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('cohere.command')) {\n BedrockRuntimeServiceExtension.recordCohereAttributes(\n parsedChunk,\n span\n );\n } else if (modelId.includes('mistral')) {\n BedrockRuntimeServiceExtension.recordMistralAttributes(\n parsedChunk,\n span\n );\n }\n yield chunk;\n }\n } finally {\n span.end();\n }\n }.bind(this)();\n return response.data;\n }\n\n private parseChunk(bytes?: Uint8Array): any {\n if (!bytes || !(bytes instanceof Uint8Array)) return null;\n try {\n const str = Buffer.from(bytes).toString('utf-8');\n return JSON.parse(str);\n } catch (err) {\n this._diag.warn('Failed to parse streamed chunk', err);\n return null;\n }\n }\n\n private static recordNovaAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.metadata?.usage !== undefined) {\n if (parsedChunk.metadata?.usage.inputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n parsedChunk.metadata.usage.inputTokens\n );\n }\n if (parsedChunk.metadata?.usage.outputTokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n parsedChunk.metadata.usage.outputTokens\n );\n }\n }\n if (parsedChunk.messageStop?.stopReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.messageStop.stopReason,\n ]);\n }\n }\n\n private static recordClaudeAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.message?.usage?.input_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n parsedChunk.message.usage.input_tokens\n );\n }\n if (parsedChunk.message?.usage?.output_tokens !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n parsedChunk.message.usage.output_tokens\n );\n }\n if (parsedChunk.delta?.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.delta.stop_reason,\n ]);\n }\n }\n\n private static recordTitanAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.inputTextTokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n parsedChunk.inputTextTokenCount\n );\n }\n if (parsedChunk.totalOutputTextTokenCount !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n parsedChunk.totalOutputTextTokenCount\n );\n }\n if (parsedChunk.completionReason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.completionReason,\n ]);\n }\n }\n private static recordLlamaAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.prompt_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_INPUT_TOKENS,\n parsedChunk.prompt_token_count\n );\n }\n if (parsedChunk.generation_token_count !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n parsedChunk.generation_token_count\n );\n }\n if (parsedChunk.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.stop_reason,\n ]);\n }\n }\n\n private static recordMistralAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.outputs?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(parsedChunk.outputs[0].text.length / 6)\n );\n }\n if (parsedChunk.outputs?.[0]?.stop_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.outputs[0].stop_reason,\n ]);\n }\n }\n\n private static recordCohereAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.generations?.[0]?.text !== undefined) {\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n Math.ceil(parsedChunk.generations[0].text.length / 6)\n );\n }\n if (parsedChunk.generations?.[0]?.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.generations[0].finish_reason,\n ]);\n }\n }\n\n private static recordCohereRAttributes(parsedChunk: any, span: Span) {\n if (parsedChunk.text !== undefined) {\n // NOTE: We approximate the token count since this value is not directly available in the body\n // According to Bedrock docs they use (total_chars / 6) to approximate token count for pricing.\n // https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-prepare.html\n span.setAttribute(\n ATTR_GEN_AI_USAGE_OUTPUT_TOKENS,\n Math.ceil(parsedChunk.text.length / 6)\n );\n }\n if (parsedChunk.finish_reason !== undefined) {\n span.setAttribute(ATTR_GEN_AI_RESPONSE_FINISH_REASONS, [\n parsedChunk.finish_reason,\n ]);\n }\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.61.2";
1
+ export declare const PACKAGE_VERSION = "0.63.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-aws-sdk";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -17,6 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.61.2';
20
+ exports.PACKAGE_VERSION = '0.63.0';
21
21
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-aws-sdk';
22
22
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.61.2';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-aws-sdk';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.63.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-aws-sdk';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-aws-sdk",
3
- "version": "0.61.2",
3
+ "version": "0.63.0",
4
4
  "description": "OpenTelemetry instrumentation for `aws-sdk` and `@aws-sdk/client-*` clients for various AWS services",
5
5
  "keywords": [
6
6
  "aws",
@@ -34,8 +34,6 @@
34
34
  "clean": "rimraf build/*",
35
35
  "compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-aws-sdk",
36
36
  "compile": "tsc -p .",
37
- "lint": "eslint . --ext=ts,js,mjs",
38
- "lint:fix": "eslint . --ext=ts,js,mjs --fix",
39
37
  "lint:readme": "node ../../scripts/lint-readme.js",
40
38
  "prepublishOnly": "npm run compile",
41
39
  "tdd": "npm run test -- --watch-extensions ts --watch",
@@ -49,7 +47,7 @@
49
47
  },
50
48
  "dependencies": {
51
49
  "@opentelemetry/core": "^2.0.0",
52
- "@opentelemetry/instrumentation": "^0.205.0",
50
+ "@opentelemetry/instrumentation": "^0.207.0",
53
51
  "@opentelemetry/semantic-conventions": "^1.34.0"
54
52
  },
55
53
  "devDependencies": {
@@ -64,13 +62,12 @@
64
62
  "@aws-sdk/client-sqs": "^3.85.0",
65
63
  "@aws-sdk/types": "^3.370.0",
66
64
  "@opentelemetry/api": "^1.3.0",
67
- "@opentelemetry/contrib-test-utils": "^0.52.2",
65
+ "@opentelemetry/contrib-test-utils": "^0.54.0",
68
66
  "@opentelemetry/sdk-trace-base": "^2.0.0",
69
67
  "@smithy/node-http-handler": "4.1.1",
70
68
  "@types/mocha": "10.0.10",
71
69
  "@types/node": "18.18.14",
72
70
  "@types/sinon": "17.0.4",
73
- "eslint": "8.7.0",
74
71
  "expect": "29.2.0",
75
72
  "nock": "13.3.3",
76
73
  "nyc": "17.1.0",
@@ -82,5 +79,5 @@
82
79
  "engines": {
83
80
  "node": "^18.19.0 || >=20.6.0"
84
81
  },
85
- "gitHead": "5a5918fd4f9f16b14c9ef4d3de08ab98c20e5b46"
82
+ "gitHead": "2801ab2f0f9243b154a624298dacb7228c4f70cd"
86
83
  }