@opentelemetry/instrumentation-aws-sdk 0.38.1 → 0.39.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":"dynamodb.js","sourceRoot":"","sources":["../../../src/services/dynamodb.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAAwE;AAExE,8EAG6C;AAO7C,MAAa,wBAAwB;IACnC,OAAO,CAAI,MAAe;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,kBAAkB,CAChB,iBAAoC,EACpC,MAAmC,EACnC,IAAgB;;QAEhB,MAAM,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QAC3C,IAAI,QAA4B,CAAC;QACjC,MAAM,UAAU,GAAG,KAAK,CAAC;QACzB,MAAM,SAAS,GAAG,iBAAiB,CAAC,WAAW,CAAC;QAEhD,MAAM,cAAc,GAAG;YACrB,CAAC,yCAAkB,CAAC,SAAS,CAAC,EAAE,qCAAc,CAAC,QAAQ;YACvD,CAAC,yCAAkB,CAAC,OAAO,CAAC,EAAE,MAAA,iBAAiB,CAAC,YAAY,0CAAE,SAAS;YACvE,CAAC,yCAAkB,CAAC,YAAY,CAAC,EAAE,SAAS;SAC7C,CAAC;QAEF,IAAI,MAAM,CAAC,2BAA2B,EAAE;YACtC,IAAI;gBACF,MAAM,kBAAkB,GAAG,MAAM,CAAC,2BAA2B,CAC3D,SAAS,EACT,iBAAiB,CAAC,YAAY,CAC/B,CAAC;gBAEF,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;oBAC1C,cAAc,CAAC,yCAAkB,CAAC,YAAY,CAAC,GAAG,kBAAkB,CAAC;iBACtE;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAA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AAE,UAAU,EAAE;YAC7B,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,wBAAwB,EAC3C,MAAA,QAAQ,CAAC,IAAI,0CAAE,UAAU,CAAC,MAAM,CACjC,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,EAAE;YACxB,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,kBAAkB,EACrC,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,CACrB,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,YAAY,EAAE;YAC/B,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,0BAA0B,EAC7C,MAAA,QAAQ,CAAC,IAAI,0CAAE,YAAY,CAC5B,CAAC;SACH;IACH,CAAC;CACF;AAnOD,4DAmOC;AAED,SAAS,OAAO,CAAI,MAAe;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,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 */\nimport { DiagLogger, Span, SpanKind, Tracer } from '@opentelemetry/api';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport {\n DbSystemValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\n\nexport class DynamodbServiceExtension implements ServiceExtension {\n toArray<T>(values: T | T[]): T[] {\n return Array.isArray(values) ? values : [values];\n }\n\n requestPreSpanHook(\n normalizedRequest: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n const spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n const isIncoming = false;\n const operation = normalizedRequest.commandName;\n\n const spanAttributes = {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.DYNAMODB,\n [SemanticAttributes.DB_NAME]: normalizedRequest.commandInput?.TableName,\n [SemanticAttributes.DB_OPERATION]: operation,\n };\n\n if (config.dynamoDBStatementSerializer) {\n try {\n const sanitizedStatement = config.dynamoDBStatementSerializer(\n operation,\n normalizedRequest.commandInput\n );\n\n if (typeof sanitizedStatement === 'string') {\n spanAttributes[SemanticAttributes.DB_STATEMENT] = sanitizedStatement;\n }\n } catch (err) {\n diag.error('failed to sanitize DynamoDB statement', err);\n }\n }\n\n // normalizedRequest.commandInput.RequestItems) is undefined when no table names are returned\n // keys in this object are the table names\n if (normalizedRequest.commandInput?.TableName) {\n // Necessary for commands with only 1 table name (example: CreateTable). Attribute is TableName not keys of RequestItems\n // single table name returned for operations like CreateTable\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = [\n normalizedRequest.commandInput.TableName,\n ];\n } else if (normalizedRequest.commandInput?.RequestItems) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = Object.keys(\n normalizedRequest.commandInput.RequestItems\n );\n }\n\n if (operation === 'CreateTable' || operation === 'UpdateTable') {\n // only check for ProvisionedThroughput since ReadCapacityUnits and WriteCapacity units are required attributes\n if (normalizedRequest.commandInput?.ProvisionedThroughput) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_PROVISIONED_READ_CAPACITY\n ] =\n normalizedRequest.commandInput.ProvisionedThroughput.ReadCapacityUnits;\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY\n ] =\n normalizedRequest.commandInput.ProvisionedThroughput.WriteCapacityUnits;\n }\n }\n\n if (\n operation === 'GetItem' ||\n operation === 'Scan' ||\n operation === 'Query'\n ) {\n if (normalizedRequest.commandInput?.ConsistentRead) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_CONSISTENT_READ] =\n normalizedRequest.commandInput.ConsistentRead;\n }\n }\n\n if (operation === 'Query' || operation === 'Scan') {\n if (normalizedRequest.commandInput?.ProjectionExpression) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_PROJECTION] =\n normalizedRequest.commandInput.ProjectionExpression;\n }\n }\n\n if (operation === 'CreateTable') {\n if (normalizedRequest.commandInput?.GlobalSecondaryIndexes) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES\n ] = this.toArray(\n normalizedRequest.commandInput.GlobalSecondaryIndexes\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n\n if (normalizedRequest.commandInput?.LocalSecondaryIndexes) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES\n ] = this.toArray(\n normalizedRequest.commandInput.LocalSecondaryIndexes\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n }\n\n if (\n operation === 'ListTables' ||\n operation === 'Query' ||\n operation === 'Scan'\n ) {\n if (normalizedRequest.commandInput?.Limit) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_LIMIT] =\n normalizedRequest.commandInput.Limit;\n }\n }\n\n if (operation === 'ListTables') {\n if (normalizedRequest.commandInput?.ExclusiveStartTableName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_EXCLUSIVE_START_TABLE] =\n normalizedRequest.commandInput.ExclusiveStartTableName;\n }\n }\n\n if (operation === 'Query') {\n if (normalizedRequest.commandInput?.ScanIndexForward) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SCAN_FORWARD] =\n normalizedRequest.commandInput.ScanIndexForward;\n }\n\n if (normalizedRequest.commandInput?.IndexName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =\n normalizedRequest.commandInput.IndexName;\n }\n\n if (normalizedRequest.commandInput?.Select) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SELECT] =\n normalizedRequest.commandInput.Select;\n }\n }\n\n if (operation === 'Scan') {\n if (normalizedRequest.commandInput?.Segment) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SEGMENT] =\n normalizedRequest.commandInput?.Segment;\n }\n\n if (normalizedRequest.commandInput?.TotalSegments) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TOTAL_SEGMENTS] =\n normalizedRequest.commandInput?.TotalSegments;\n }\n\n if (normalizedRequest.commandInput?.IndexName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =\n normalizedRequest.commandInput.IndexName;\n }\n\n if (normalizedRequest.commandInput?.Select) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SELECT] =\n normalizedRequest.commandInput.Select;\n }\n }\n\n if (operation === 'UpdateTable') {\n if (normalizedRequest.commandInput?.AttributeDefinitions) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS] =\n this.toArray(normalizedRequest.commandInput.AttributeDefinitions).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n );\n }\n\n if (normalizedRequest.commandInput?.GlobalSecondaryIndexUpdates) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES\n ] = this.toArray(\n normalizedRequest.commandInput.GlobalSecondaryIndexUpdates\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n _tracer: Tracer,\n _config: AwsSdkInstrumentationConfig\n ) {\n if (response.data?.ConsumedCapacity) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_CONSUMED_CAPACITY,\n toArray(response.data.ConsumedCapacity).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\n );\n }\n\n if (response.data?.ItemCollectionMetrics) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_ITEM_COLLECTION_METRICS,\n this.toArray(response.data.ItemCollectionMetrics).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\n );\n }\n\n if (response.data?.TableNames) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_TABLE_COUNT,\n response.data?.TableNames.length\n );\n }\n\n if (response.data?.Count) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_COUNT,\n response.data?.Count\n );\n }\n\n if (response.data?.ScannedCount) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_SCANNED_COUNT,\n response.data?.ScannedCount\n );\n }\n }\n}\n\nfunction toArray<T>(values: T | T[]): T[] {\n return Array.isArray(values) ? values : [values];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dynamodb.js","sourceRoot":"","sources":["../../../src/services/dynamodb.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAE5B,8EAG6C;AAO7C,MAAa,wBAAwB;IACnC,OAAO,CAAI,MAAe;QACxB,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,kBAAkB,CAChB,iBAAoC,EACpC,MAAmC,EACnC,IAAgB;;QAEhB,MAAM,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QAC3C,IAAI,QAA4B,CAAC;QACjC,MAAM,UAAU,GAAG,KAAK,CAAC;QACzB,MAAM,SAAS,GAAG,iBAAiB,CAAC,WAAW,CAAC;QAEhD,MAAM,cAAc,GAAmB;YACrC,CAAC,yCAAkB,CAAC,SAAS,CAAC,EAAE,qCA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,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,GAAG,CACzC,CAAC,CAAmC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAC3D,CACF,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,qBAAqB,EAAE;YACxC,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,oCAAoC,EACvD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,GAAG,CACnD,CAAC,CAAmC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAC3D,CACF,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,UAAU,EAAE;YAC7B,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,wBAAwB,EAC3C,MAAA,QAAQ,CAAC,IAAI,0CAAE,UAAU,CAAC,MAAM,CACjC,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,EAAE;YACxB,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,kBAAkB,EACrC,MAAA,QAAQ,CAAC,IAAI,0CAAE,KAAK,CACrB,CAAC;SACH;QAED,IAAI,MAAA,QAAQ,CAAC,IAAI,0CAAE,YAAY,EAAE;YAC/B,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,0BAA0B,EAC7C,MAAA,QAAQ,CAAC,IAAI,0CAAE,YAAY,CAC5B,CAAC;SACH;IACH,CAAC;CACF;AAnOD,4DAmOC;AAED,SAAS,OAAO,CAAI,MAAe;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,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 */\nimport {\n DiagLogger,\n Span,\n SpanAttributes,\n SpanKind,\n Tracer,\n} from '@opentelemetry/api';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport {\n DbSystemValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\n\nexport class DynamodbServiceExtension implements ServiceExtension {\n toArray<T>(values: T | T[]): T[] {\n return Array.isArray(values) ? values : [values];\n }\n\n requestPreSpanHook(\n normalizedRequest: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n const spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n const isIncoming = false;\n const operation = normalizedRequest.commandName;\n\n const spanAttributes: SpanAttributes = {\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.DYNAMODB,\n [SemanticAttributes.DB_NAME]: normalizedRequest.commandInput?.TableName,\n [SemanticAttributes.DB_OPERATION]: operation,\n };\n\n if (config.dynamoDBStatementSerializer) {\n try {\n const sanitizedStatement = config.dynamoDBStatementSerializer(\n operation,\n normalizedRequest.commandInput\n );\n\n if (typeof sanitizedStatement === 'string') {\n spanAttributes[SemanticAttributes.DB_STATEMENT] = sanitizedStatement;\n }\n } catch (err) {\n diag.error('failed to sanitize DynamoDB statement', err);\n }\n }\n\n // normalizedRequest.commandInput.RequestItems) is undefined when no table names are returned\n // keys in this object are the table names\n if (normalizedRequest.commandInput?.TableName) {\n // Necessary for commands with only 1 table name (example: CreateTable). Attribute is TableName not keys of RequestItems\n // single table name returned for operations like CreateTable\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = [\n normalizedRequest.commandInput.TableName,\n ];\n } else if (normalizedRequest.commandInput?.RequestItems) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = Object.keys(\n normalizedRequest.commandInput.RequestItems\n );\n }\n\n if (operation === 'CreateTable' || operation === 'UpdateTable') {\n // only check for ProvisionedThroughput since ReadCapacityUnits and WriteCapacity units are required attributes\n if (normalizedRequest.commandInput?.ProvisionedThroughput) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_PROVISIONED_READ_CAPACITY\n ] =\n normalizedRequest.commandInput.ProvisionedThroughput.ReadCapacityUnits;\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY\n ] =\n normalizedRequest.commandInput.ProvisionedThroughput.WriteCapacityUnits;\n }\n }\n\n if (\n operation === 'GetItem' ||\n operation === 'Scan' ||\n operation === 'Query'\n ) {\n if (normalizedRequest.commandInput?.ConsistentRead) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_CONSISTENT_READ] =\n normalizedRequest.commandInput.ConsistentRead;\n }\n }\n\n if (operation === 'Query' || operation === 'Scan') {\n if (normalizedRequest.commandInput?.ProjectionExpression) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_PROJECTION] =\n normalizedRequest.commandInput.ProjectionExpression;\n }\n }\n\n if (operation === 'CreateTable') {\n if (normalizedRequest.commandInput?.GlobalSecondaryIndexes) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES\n ] = this.toArray(\n normalizedRequest.commandInput.GlobalSecondaryIndexes\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n\n if (normalizedRequest.commandInput?.LocalSecondaryIndexes) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES\n ] = this.toArray(\n normalizedRequest.commandInput.LocalSecondaryIndexes\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n }\n\n if (\n operation === 'ListTables' ||\n operation === 'Query' ||\n operation === 'Scan'\n ) {\n if (normalizedRequest.commandInput?.Limit) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_LIMIT] =\n normalizedRequest.commandInput.Limit;\n }\n }\n\n if (operation === 'ListTables') {\n if (normalizedRequest.commandInput?.ExclusiveStartTableName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_EXCLUSIVE_START_TABLE] =\n normalizedRequest.commandInput.ExclusiveStartTableName;\n }\n }\n\n if (operation === 'Query') {\n if (normalizedRequest.commandInput?.ScanIndexForward) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SCAN_FORWARD] =\n normalizedRequest.commandInput.ScanIndexForward;\n }\n\n if (normalizedRequest.commandInput?.IndexName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =\n normalizedRequest.commandInput.IndexName;\n }\n\n if (normalizedRequest.commandInput?.Select) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SELECT] =\n normalizedRequest.commandInput.Select;\n }\n }\n\n if (operation === 'Scan') {\n if (normalizedRequest.commandInput?.Segment) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SEGMENT] =\n normalizedRequest.commandInput?.Segment;\n }\n\n if (normalizedRequest.commandInput?.TotalSegments) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TOTAL_SEGMENTS] =\n normalizedRequest.commandInput?.TotalSegments;\n }\n\n if (normalizedRequest.commandInput?.IndexName) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =\n normalizedRequest.commandInput.IndexName;\n }\n\n if (normalizedRequest.commandInput?.Select) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_SELECT] =\n normalizedRequest.commandInput.Select;\n }\n }\n\n if (operation === 'UpdateTable') {\n if (normalizedRequest.commandInput?.AttributeDefinitions) {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS] =\n this.toArray(normalizedRequest.commandInput.AttributeDefinitions).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n );\n }\n\n if (normalizedRequest.commandInput?.GlobalSecondaryIndexUpdates) {\n spanAttributes[\n SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES\n ] = this.toArray(\n normalizedRequest.commandInput.GlobalSecondaryIndexUpdates\n ).map((x: { [DictionaryKey: string]: any }) => JSON.stringify(x));\n }\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n _tracer: Tracer,\n _config: AwsSdkInstrumentationConfig\n ) {\n if (response.data?.ConsumedCapacity) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_CONSUMED_CAPACITY,\n toArray(response.data.ConsumedCapacity).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\n );\n }\n\n if (response.data?.ItemCollectionMetrics) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_ITEM_COLLECTION_METRICS,\n this.toArray(response.data.ItemCollectionMetrics).map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\n );\n }\n\n if (response.data?.TableNames) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_TABLE_COUNT,\n response.data?.TableNames.length\n );\n }\n\n if (response.data?.Count) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_COUNT,\n response.data?.Count\n );\n }\n\n if (response.data?.ScannedCount) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_SCANNED_COUNT,\n response.data?.ScannedCount\n );\n }\n }\n}\n\nfunction toArray<T>(values: T | T[]): T[] {\n return Array.isArray(values) ? values : [values];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sns.js","sourceRoot":"","sources":["../../../src/services/sns.ts"],"names":[],"m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AAW,KAAK,SAAS,EAAE;YACrC,MAAM,qBAAqB,GACzB,MAAA,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,mCAAI,EAAE,CAAC;YAClD,IAAI,qBAAqB,EAAE;gBACzB,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,GAAG,IAAA,4CAAwB,EAClE,qBAAqB,CACtB,CAAC;aACH;SACF;IACH,CAAC;IAED,YAAY,CACV,QAA4B,EAC5B,IAAU,EACV,MAAc,EACd,MAAmC,IAC5B,CAAC;IAEV,sBAAsB,CACpB,QAAgB,EAChB,SAAiB,EACjB,WAAmB;QAEnB,IAAI,QAAQ,IAAI,SAAS,EAAE;YACzB,MAAM,GAAG,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,SAAS,CAAC;YAClC,IAAI;gBACF,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;aAC7C;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,GAAG,CAAC;aACZ;SACF;aAAM,IAAI,WAAW,EAAE;YACtB,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;CACF;AA3ED,kDA2EC","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 { Span, Tracer, SpanKind, SpanAttributes } from '@opentelemetry/api';\nimport {\n MessagingDestinationKindValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n NormalizedRequest,\n NormalizedResponse,\n AwsSdkInstrumentationConfig,\n} from '../types';\nimport { injectPropagationContext } from './MessageAttributes';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\n\nexport class SnsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n let spanKind: SpanKind = SpanKind.CLIENT;\n let spanName = `SNS ${request.commandName}`;\n const spanAttributes: SpanAttributes = {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'aws.sns',\n };\n\n if (request.commandName === 'Publish') {\n spanKind = SpanKind.PRODUCER;\n\n spanAttributes[SemanticAttributes.MESSAGING_DESTINATION_KIND] =\n MessagingDestinationKindValues.TOPIC;\n const { TopicArn, TargetArn, PhoneNumber } = request.commandInput;\n spanAttributes[SemanticAttributes.MESSAGING_DESTINATION] =\n this.extractDestinationName(TopicArn, TargetArn, PhoneNumber);\n // ToDO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when implemented\n spanAttributes['messaging.destination.name'] =\n TopicArn || TargetArn || PhoneNumber || 'unknown';\n\n spanName = `${\n PhoneNumber\n ? 'phone_number'\n : spanAttributes[SemanticAttributes.MESSAGING_DESTINATION]\n } send`;\n }\n\n return {\n isIncoming: false,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n requestPostSpanHook(request: NormalizedRequest): void {\n if (request.commandName === 'Publish') {\n const origMessageAttributes =\n request.commandInput['MessageAttributes'] ?? {};\n if (origMessageAttributes) {\n request.commandInput['MessageAttributes'] = injectPropagationContext(\n origMessageAttributes\n );\n }\n }\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ): void {}\n\n extractDestinationName(\n topicArn: string,\n targetArn: string,\n phoneNumber: string\n ): string {\n if (topicArn || targetArn) {\n const arn = topicArn ?? targetArn;\n try {\n return arn.substr(arn.lastIndexOf(':') + 1);\n } catch (err) {\n return arn;\n }\n } else if (phoneNumber) {\n return phoneNumber;\n }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;QAEF,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,gBAAgB;gBACnB;oBACE,UAAU,GAAG,IAAI,CAAC;oBAClB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;oBAC7B,QAAQ,GAAG,GAAG,SAAS,UAAU,CAAC;oBAClC,cAAc,CAAC,yCAAkB,CAAC,mBAAmB,CAAC;wBACpD,+CAAwB,CAAC,OAAO,CAAC;oBAEnC,OAAO,CAAC,YAAY,CAAC,qBAAqB;wBACxC,IAAA,wDAAoC,EAClC,OAAO,CAAC,YAAY,CAAC,qBAAqB,EAC1C,iBAAW,CAAC,MAAM,EAAE,CACrB,CAAC;iBACL;gBACD,MAAM;YAER,KAAK,aAAa,CAAC;YACnB,KAAK,kBAAkB;gBACrB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;gBAC7B,QAAQ,GAAG,GAAG,SAAS,OAAO,CAAC;gBAC/B,MAAM;SACT;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;CAyGF;AA3JD,kDA2JC","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 Tracer,\n SpanKind,\n Span,\n propagation,\n trace,\n context,\n ROOT_CONTEXT,\n} from '@opentelemetry/api';\nimport { pubsubPropagation } from '@opentelemetry/propagation-utils';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport type { SQS } from 'aws-sdk';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport {\n MessagingDestinationKindValues,\n MessagingOperationValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n contextGetter,\n extractPropagationContext,\n injectPropagationContext,\n addPropagationFieldsToAttributeNames,\n} from './MessageAttributes';\n\nexport class SqsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const queueUrl = this.extractQueueUrl(request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n let spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n\n const spanAttributes = {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'aws.sqs',\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.QUEUE,\n [SemanticAttributes.MESSAGING_DESTINATION]: queueName,\n [SemanticAttributes.MESSAGING_URL]: queueUrl,\n };\n\n let isIncoming = false;\n\n switch (request.commandName) {\n case 'ReceiveMessage':\n {\n isIncoming = true;\n spanKind = SpanKind.CONSUMER;\n spanName = `${queueName} receive`;\n spanAttributes[SemanticAttributes.MESSAGING_OPERATION] =\n MessagingOperationValues.RECEIVE;\n\n request.commandInput.MessageAttributeNames =\n addPropagationFieldsToAttributeNames(\n request.commandInput.MessageAttributeNames,\n propagation.fields()\n );\n }\n break;\n\n case 'SendMessage':\n case 'SendMessageBatch':\n spanKind = SpanKind.PRODUCER;\n spanName = `${queueName} send`;\n break;\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n requestPostSpanHook = (request: NormalizedRequest) => {\n switch (request.commandName) {\n case 'SendMessage':\n {\n const origMessageAttributes =\n request.commandInput['MessageAttributes'] ?? {};\n if (origMessageAttributes) {\n request.commandInput['MessageAttributes'] =\n injectPropagationContext(origMessageAttributes);\n }\n }\n break;\n\n case 'SendMessageBatch':\n {\n request.commandInput?.Entries?.forEach(\n (messageParams: SQS.SendMessageBatchRequestEntry) => {\n messageParams.MessageAttributes = injectPropagationContext(\n messageParams.MessageAttributes ?? {}\n );\n }\n );\n }\n break;\n }\n };\n\n responseHook = (\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) => {\n switch (response.request.commandName) {\n case 'SendMessage':\n span.setAttribute(\n SemanticAttributes.MESSAGING_MESSAGE_ID,\n response?.data?.MessageId\n );\n break;\n\n case 'SendMessageBatch':\n // TODO: How should this be handled?\n break;\n\n case 'ReceiveMessage': {\n const messages: SQS.Message[] = response?.data?.Messages;\n if (messages) {\n const queueUrl = this.extractQueueUrl(response.request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n\n pubsubPropagation.patchMessagesArrayToStartProcessSpans<SQS.Message>({\n messages,\n parentContext: trace.setSpan(context.active(), span),\n tracer,\n messageToSpanDetails: (message: SQS.Message) => ({\n name: queueName ?? 'unknown',\n parentContext: propagation.extract(\n ROOT_CONTEXT,\n extractPropagationContext(\n message,\n config.sqsExtractContextPropagationFromPayload\n ),\n contextGetter\n ),\n attributes: {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'aws.sqs',\n [SemanticAttributes.MESSAGING_DESTINATION]: queueName,\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.QUEUE,\n [SemanticAttributes.MESSAGING_MESSAGE_ID]: message.MessageId,\n [SemanticAttributes.MESSAGING_URL]: queueUrl,\n [SemanticAttributes.MESSAGING_OPERATION]:\n MessagingOperationValues.PROCESS,\n },\n }),\n processHook: (span: Span, message: SQS.Message) =>\n config.sqsProcessHook?.(span, { message }),\n });\n\n pubsubPropagation.patchArrayForProcessSpans(\n messages,\n tracer,\n context.active()\n );\n }\n break;\n }\n }\n };\n\n extractQueueUrl = (commandInput: Record<string, any>): string => {\n return commandInput?.QueueUrl;\n };\n\n extractQueueNameFromUrl = (queueUrl: string): string | undefined => {\n if (!queueUrl) return undefined;\n\n const segments = queueUrl.split('/');\n if (segments.length === 0) return undefined;\n\n return segments[segments.length - 1];\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sqs.js","sourceRoot":"","sources":["../../../src/services/sqs.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAS4B;AAC5B,wEAAqE;AAQrE,8EAI6C;AAC7C,2DAK6B;AAE7B,MAAa,mBAAmB;IAAhC;QAoDE,wBAAmB,GAAG,CAAC,OAA0B,EAAE,EAAE;;YACnD,QAAQ,OAAO,CAAC,WAAW,EAAE;gBAC3B,KAAK,aAAa;oBAChB;wBACE,MAAM,qBAAqB,GACzB,MAAA,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC,mCAAI,EAAE,CAAC;wBAClD,IAAI,qBAAqB,EAAE;4BACzB,OAAO,CAAC,YAAY,CAAC,mBAAmB,CAAC;gCACvC,IAAA,4CAAwB,EAAC,qBAAqB,CAAC,CAAC;yBACnD;qBACF;oBACD,MAAM;gBAER,KAAK,kBAAkB;oBACrB;wBACE,MAAA,MAAA,OAAO,CAAC,YAAY,0CAAE,OAAO,0CAAE,OAAO,CACpC,CAAC,aAA+C,EAAE,EAAE;;4BAClD,aAAa,CAAC,iBAAiB,GAAG,IAAA,4CAAwB,EACxD,MAAA,aAAa,CAAC,iBAAiB,mCAAI,EAAE,CACtC,CAAC;wBACJ,CAAC,CACF,CAAC;qBACH;oBACD,MAAM;aACT;QACH,CAAC,CAAC;QAEF,iBAAY,GAAG,CACb,QAA4B,EAC5B,IAAU,EACV,MAAc,EACd,MAAmC,EACnC,EAAE;;YACF,QAAQ,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE;gBACpC,KAAK,aAAa;oBAChB,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,oBAAoB,EACvC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,SAAS,CAC1B,CAAC;oBACF,MAAM;gBAER,KAAK,kBA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AAE,QAAQ;SAC7C,CAAC;QAEF,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,gBAAgB;gBACnB;oBACE,UAAU,GAAG,IAAI,CAAC;oBAClB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;oBAC7B,QAAQ,GAAG,GAAG,SAAS,UAAU,CAAC;oBAClC,cAAc,CAAC,yCAAkB,CAAC,mBAAmB,CAAC;wBACpD,+CAAwB,CAAC,OAAO,CAAC;oBAEnC,OAAO,CAAC,YAAY,CAAC,qBAAqB;wBACxC,IAAA,wDAAoC,EAClC,OAAO,CAAC,YAAY,CAAC,qBAAqB,EAC1C,iBAAW,CAAC,MAAM,EAAE,CACrB,CAAC;iBACL;gBACD,MAAM;YAER,KAAK,aAAa,CAAC;YACnB,KAAK,kBAAkB;gBACrB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;gBAC7B,QAAQ,GAAG,GAAG,SAAS,OAAO,CAAC;gBAC/B,MAAM;SACT;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;CAyGF;AA3JD,kDA2JC","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 Tracer,\n SpanKind,\n Span,\n propagation,\n trace,\n context,\n ROOT_CONTEXT,\n SpanAttributes,\n} from '@opentelemetry/api';\nimport { pubsubPropagation } from '@opentelemetry/propagation-utils';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport type { SQS } from 'aws-sdk';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport {\n MessagingDestinationKindValues,\n MessagingOperationValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n contextGetter,\n extractPropagationContext,\n injectPropagationContext,\n addPropagationFieldsToAttributeNames,\n} from './MessageAttributes';\n\nexport class SqsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const queueUrl = this.extractQueueUrl(request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n let spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n\n const spanAttributes: SpanAttributes = {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'aws.sqs',\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.QUEUE,\n [SemanticAttributes.MESSAGING_DESTINATION]: queueName,\n [SemanticAttributes.MESSAGING_URL]: queueUrl,\n };\n\n let isIncoming = false;\n\n switch (request.commandName) {\n case 'ReceiveMessage':\n {\n isIncoming = true;\n spanKind = SpanKind.CONSUMER;\n spanName = `${queueName} receive`;\n spanAttributes[SemanticAttributes.MESSAGING_OPERATION] =\n MessagingOperationValues.RECEIVE;\n\n request.commandInput.MessageAttributeNames =\n addPropagationFieldsToAttributeNames(\n request.commandInput.MessageAttributeNames,\n propagation.fields()\n );\n }\n break;\n\n case 'SendMessage':\n case 'SendMessageBatch':\n spanKind = SpanKind.PRODUCER;\n spanName = `${queueName} send`;\n break;\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n requestPostSpanHook = (request: NormalizedRequest) => {\n switch (request.commandName) {\n case 'SendMessage':\n {\n const origMessageAttributes =\n request.commandInput['MessageAttributes'] ?? {};\n if (origMessageAttributes) {\n request.commandInput['MessageAttributes'] =\n injectPropagationContext(origMessageAttributes);\n }\n }\n break;\n\n case 'SendMessageBatch':\n {\n request.commandInput?.Entries?.forEach(\n (messageParams: SQS.SendMessageBatchRequestEntry) => {\n messageParams.MessageAttributes = injectPropagationContext(\n messageParams.MessageAttributes ?? {}\n );\n }\n );\n }\n break;\n }\n };\n\n responseHook = (\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) => {\n switch (response.request.commandName) {\n case 'SendMessage':\n span.setAttribute(\n SemanticAttributes.MESSAGING_MESSAGE_ID,\n response?.data?.MessageId\n );\n break;\n\n case 'SendMessageBatch':\n // TODO: How should this be handled?\n break;\n\n case 'ReceiveMessage': {\n const messages: SQS.Message[] = response?.data?.Messages;\n if (messages) {\n const queueUrl = this.extractQueueUrl(response.request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n\n pubsubPropagation.patchMessagesArrayToStartProcessSpans<SQS.Message>({\n messages,\n parentContext: trace.setSpan(context.active(), span),\n tracer,\n messageToSpanDetails: (message: SQS.Message) => ({\n name: queueName ?? 'unknown',\n parentContext: propagation.extract(\n ROOT_CONTEXT,\n extractPropagationContext(\n message,\n config.sqsExtractContextPropagationFromPayload\n ),\n contextGetter\n ),\n attributes: {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'aws.sqs',\n [SemanticAttributes.MESSAGING_DESTINATION]: queueName,\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.QUEUE,\n [SemanticAttributes.MESSAGING_MESSAGE_ID]: message.MessageId,\n [SemanticAttributes.MESSAGING_URL]: queueUrl,\n [SemanticAttributes.MESSAGING_OPERATION]:\n MessagingOperationValues.PROCESS,\n },\n }),\n processHook: (span: Span, message: SQS.Message) =>\n config.sqsProcessHook?.(span, { message }),\n });\n\n pubsubPropagation.patchArrayForProcessSpans(\n messages,\n tracer,\n context.active()\n );\n }\n break;\n }\n }\n };\n\n extractQueueUrl = (commandInput: Record<string, any>): string => {\n return commandInput?.QueueUrl;\n };\n\n extractQueueNameFromUrl = (queueUrl: string): string | undefined => {\n if (!queueUrl) return undefined;\n\n const segments = queueUrl.split('/');\n if (segments.length === 0) return undefined;\n\n return segments[segments.length - 1];\n };\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.39.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,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 VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,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 VERSION = '0.39.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-aws-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "OpenTelemetry automatic instrumentation for the `aws-sdk` package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentelemetry/core": "^1.8.0",
|
|
48
|
-
"@opentelemetry/instrumentation": "^0.
|
|
49
|
-
"@opentelemetry/propagation-utils": "^0.30.
|
|
48
|
+
"@opentelemetry/instrumentation": "^0.49.1",
|
|
49
|
+
"@opentelemetry/propagation-utils": "^0.30.7",
|
|
50
50
|
"@opentelemetry/semantic-conventions": "^1.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@aws-sdk/client-sqs": "3.85.0",
|
|
58
58
|
"@aws-sdk/types": "3.78.0",
|
|
59
59
|
"@opentelemetry/api": "^1.3.0",
|
|
60
|
-
"@opentelemetry/contrib-test-utils": "^0.
|
|
60
|
+
"@opentelemetry/contrib-test-utils": "^0.37.0",
|
|
61
61
|
"@opentelemetry/sdk-trace-base": "^1.8.0",
|
|
62
62
|
"@types/mocha": "8.2.3",
|
|
63
63
|
"@types/node": "18.6.5",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=14"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "fcea8ca0c83cb1dcd8ac736e5ea4d22ff20dc982"
|
|
81
81
|
}
|