@opentelemetry/instrumentation-aws-sdk 0.34.3 → 0.35.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,15 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
13
4
  /*
14
5
  * Copyright The OpenTelemetry Authors
15
6
  *
@@ -25,6 +16,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
16
  * See the License for the specific language governing permissions and
26
17
  * limitations under the License.
27
18
  */
28
- __exportStar(require("./aws-sdk"), exports);
29
- __exportStar(require("./types"), exports);
19
+ tslib_1.__exportStar(require("./aws-sdk"), exports);
20
+ tslib_1.__exportStar(require("./types"), exports);
30
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0B;AAC1B,0CAAwB","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 */\nexport * from './aws-sdk';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,oDAA0B;AAC1B,kDAAwB","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 */\nexport * from './aws-sdk';\nexport * from './types';\n"]}
@@ -2,6 +2,7 @@ import { Span, Tracer } from '@opentelemetry/api';
2
2
  import { RequestMetadata, ServiceExtension } from './ServiceExtension';
3
3
  import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } from '../types';
4
4
  export declare class DynamodbServiceExtension implements ServiceExtension {
5
+ toArray<T>(values: T | T[]): T[];
5
6
  requestPreSpanHook(normalizedRequest: NormalizedRequest): RequestMetadata;
6
7
  responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void;
7
8
  }
@@ -19,8 +19,11 @@ exports.DynamodbServiceExtension = void 0;
19
19
  const api_1 = require("@opentelemetry/api");
20
20
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
21
21
  class DynamodbServiceExtension {
22
+ toArray(values) {
23
+ return Array.isArray(values) ? values : [values];
24
+ }
22
25
  requestPreSpanHook(normalizedRequest) {
23
- var _a;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
24
27
  const spanKind = api_1.SpanKind.CLIENT;
25
28
  let spanName;
26
29
  const isIncoming = false;
@@ -31,9 +34,104 @@ class DynamodbServiceExtension {
31
34
  [semantic_conventions_1.SemanticAttributes.DB_OPERATION]: operation,
32
35
  [semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: JSON.stringify(normalizedRequest.commandInput),
33
36
  };
34
- if (operation === 'BatchGetItem') {
37
+ // normalizedRequest.commandInput.RequestItems) is undefined when no table names are returned
38
+ // keys in this object are the table names
39
+ if ((_b = normalizedRequest.commandInput) === null || _b === void 0 ? void 0 : _b.TableName) {
40
+ // Necessary for commands with only 1 table name (example: CreateTable). Attribute is TableName not keys of RequestItems
41
+ // single table name returned for operations like CreateTable
42
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = [
43
+ normalizedRequest.commandInput.TableName,
44
+ ];
45
+ }
46
+ else if ((_c = normalizedRequest.commandInput) === null || _c === void 0 ? void 0 : _c.RequestItems) {
35
47
  spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = Object.keys(normalizedRequest.commandInput.RequestItems);
36
48
  }
49
+ if (operation === 'CreateTable' || operation === 'UpdateTable') {
50
+ // only check for ProvisionedThroughput since ReadCapacityUnits and WriteCapacity units are required attributes
51
+ if ((_d = normalizedRequest.commandInput) === null || _d === void 0 ? void 0 : _d.ProvisionedThroughput) {
52
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_PROVISIONED_READ_CAPACITY] =
53
+ normalizedRequest.commandInput.ProvisionedThroughput.ReadCapacityUnits;
54
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_PROVISIONED_WRITE_CAPACITY] =
55
+ normalizedRequest.commandInput.ProvisionedThroughput.WriteCapacityUnits;
56
+ }
57
+ }
58
+ if (operation === 'GetItem' ||
59
+ operation === 'Scan' ||
60
+ operation === 'Query') {
61
+ if ((_e = normalizedRequest.commandInput) === null || _e === void 0 ? void 0 : _e.ConsistentRead) {
62
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_CONSISTENT_READ] =
63
+ normalizedRequest.commandInput.ConsistentRead;
64
+ }
65
+ }
66
+ if (operation === 'Query' || operation === 'Scan') {
67
+ if ((_f = normalizedRequest.commandInput) === null || _f === void 0 ? void 0 : _f.ProjectionExpression) {
68
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_PROJECTION] =
69
+ normalizedRequest.commandInput.ProjectionExpression;
70
+ }
71
+ }
72
+ if (operation === 'CreateTable') {
73
+ if ((_g = normalizedRequest.commandInput) === null || _g === void 0 ? void 0 : _g.GlobalSecondaryIndexes) {
74
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEXES] = this.toArray(normalizedRequest.commandInput.GlobalSecondaryIndexes).map((x) => JSON.stringify(x));
75
+ }
76
+ if ((_h = normalizedRequest.commandInput) === null || _h === void 0 ? void 0 : _h.LocalSecondaryIndexes) {
77
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_LOCAL_SECONDARY_INDEXES] = this.toArray(normalizedRequest.commandInput.LocalSecondaryIndexes).map((x) => JSON.stringify(x));
78
+ }
79
+ }
80
+ if (operation === 'ListTables' ||
81
+ operation === 'Query' ||
82
+ operation === 'Scan') {
83
+ if ((_j = normalizedRequest.commandInput) === null || _j === void 0 ? void 0 : _j.Limit) {
84
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_LIMIT] =
85
+ normalizedRequest.commandInput.Limit;
86
+ }
87
+ }
88
+ if (operation === 'ListTables') {
89
+ if ((_k = normalizedRequest.commandInput) === null || _k === void 0 ? void 0 : _k.ExclusiveStartTableName) {
90
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_EXCLUSIVE_START_TABLE] =
91
+ normalizedRequest.commandInput.ExclusiveStartTableName;
92
+ }
93
+ }
94
+ if (operation === 'Query') {
95
+ if ((_l = normalizedRequest.commandInput) === null || _l === void 0 ? void 0 : _l.ScanIndexForward) {
96
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_SCAN_FORWARD] =
97
+ normalizedRequest.commandInput.ScanIndexForward;
98
+ }
99
+ if ((_m = normalizedRequest.commandInput) === null || _m === void 0 ? void 0 : _m.IndexName) {
100
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =
101
+ normalizedRequest.commandInput.IndexName;
102
+ }
103
+ if ((_o = normalizedRequest.commandInput) === null || _o === void 0 ? void 0 : _o.Select) {
104
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_SELECT] =
105
+ normalizedRequest.commandInput.Select;
106
+ }
107
+ }
108
+ if (operation === 'Scan') {
109
+ if ((_p = normalizedRequest.commandInput) === null || _p === void 0 ? void 0 : _p.Segment) {
110
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_SEGMENT] =
111
+ (_q = normalizedRequest.commandInput) === null || _q === void 0 ? void 0 : _q.Segment;
112
+ }
113
+ if ((_r = normalizedRequest.commandInput) === null || _r === void 0 ? void 0 : _r.TotalSegments) {
114
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_TOTAL_SEGMENTS] =
115
+ (_s = normalizedRequest.commandInput) === null || _s === void 0 ? void 0 : _s.TotalSegments;
116
+ }
117
+ if ((_t = normalizedRequest.commandInput) === null || _t === void 0 ? void 0 : _t.IndexName) {
118
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_INDEX_NAME] =
119
+ normalizedRequest.commandInput.IndexName;
120
+ }
121
+ if ((_u = normalizedRequest.commandInput) === null || _u === void 0 ? void 0 : _u.Select) {
122
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_SELECT] =
123
+ normalizedRequest.commandInput.Select;
124
+ }
125
+ }
126
+ if (operation === 'UpdateTable') {
127
+ if ((_v = normalizedRequest.commandInput) === null || _v === void 0 ? void 0 : _v.AttributeDefinitions) {
128
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_ATTRIBUTE_DEFINITIONS] =
129
+ this.toArray(normalizedRequest.commandInput.AttributeDefinitions).map((x) => JSON.stringify(x));
130
+ }
131
+ if ((_w = normalizedRequest.commandInput) === null || _w === void 0 ? void 0 : _w.GlobalSecondaryIndexUpdates) {
132
+ spanAttributes[semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_GLOBAL_SECONDARY_INDEX_UPDATES] = this.toArray(normalizedRequest.commandInput.GlobalSecondaryIndexUpdates).map((x) => JSON.stringify(x));
133
+ }
134
+ }
37
135
  return {
38
136
  isIncoming,
39
137
  spanAttributes,
@@ -42,13 +140,25 @@ class DynamodbServiceExtension {
42
140
  };
43
141
  }
44
142
  responseHook(response, span, tracer, config) {
45
- var _a;
143
+ var _a, _b, _c, _d, _e, _f, _g, _h;
46
144
  const operation = response.request.commandName;
47
145
  if (operation === 'BatchGetItem') {
48
146
  if (Array.isArray((_a = response.data) === null || _a === void 0 ? void 0 : _a.ConsumedCapacity)) {
49
147
  span.setAttribute(semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_CONSUMED_CAPACITY, response.data.ConsumedCapacity.map((x) => JSON.stringify(x)));
50
148
  }
51
149
  }
150
+ if ((_b = response.data) === null || _b === void 0 ? void 0 : _b.ItemCollectionMetrics) {
151
+ span.setAttribute(semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_ITEM_COLLECTION_METRICS, this.toArray(response.data.ItemCollectionMetrics).map((x) => JSON.stringify(x)));
152
+ }
153
+ if ((_c = response.data) === null || _c === void 0 ? void 0 : _c.TableNames) {
154
+ span.setAttribute(semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_TABLE_COUNT, (_d = response.data) === null || _d === void 0 ? void 0 : _d.TableNames.length);
155
+ }
156
+ if ((_e = response.data) === null || _e === void 0 ? void 0 : _e.Count) {
157
+ span.setAttribute(semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_COUNT, (_f = response.data) === null || _f === void 0 ? void 0 : _f.Count);
158
+ }
159
+ if ((_g = response.data) === null || _g === void 0 ? void 0 : _g.ScannedCount) {
160
+ span.setAttribute(semantic_conventions_1.SemanticAttributes.AWS_DYNAMODB_SCANNED_COUNT, (_h = response.data) === null || _h === void 0 ? void 0 : _h.ScannedCount);
161
+ }
52
162
  }
53
163
  }
54
164
  exports.DynamodbServiceExtension = DynamodbServiceExtension;
@@ -1 +1 @@
1
- {"version":3,"file":"dynamodb.js","sourceRoot":"","sources":["../../../src/services/dynamodb.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA4D;AAE5D,8EAG6C;AAO7C,MAAa,wBAAwB;IACnC,kBAAkB,CAAC,iBAAoC;;QACrD,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;YAC5C,CAAC,yCAAkB,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAC/C,iBAAiB,CAAC,YAAY,CAC/B;SACF,CAAC;QAEF,IAAI,SAAS,KAAK,cAAc,EAAE;YAChC,cAAc,CAAC,yCAAkB,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAC,IAAI,CACvE,iBAAiB,CAAC,YAAY,CAAC,YAAY,CAC5C,CAAC;SACH;QAED,OAAO;YACL,UAAU;YACV,cAAc;YACd,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;IAED,YAAY,CACV,QAA4B,EAC5B,IAAU,EACV,MAAc,EACd,MAAmC;;QAEnC,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;QAE/C,IAAI,SAAS,KAAK,cAAc,EAAE;YAChC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAA,QAAQ,CAAC,IAAI,0CAAE,gBAAgB,CAAC,EAAE;gBAClD,IAAI,CAAC,YAAY,CACf,yCAAkB,CAAC,8BAA8B,EACjD,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAChC,CAAC,CAAmC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAC3D,CACF,CAAC;aACH;SACF;IACH,CAAC;CACF;AAjDD,4DAiDC","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, 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 requestPreSpanHook(normalizedRequest: NormalizedRequest): 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 [SemanticAttributes.DB_STATEMENT]: JSON.stringify(\n normalizedRequest.commandInput\n ),\n };\n\n if (operation === 'BatchGetItem') {\n spanAttributes[SemanticAttributes.AWS_DYNAMODB_TABLE_NAMES] = Object.keys(\n normalizedRequest.commandInput.RequestItems\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 const operation = response.request.commandName;\n\n if (operation === 'BatchGetItem') {\n if (Array.isArray(response.data?.ConsumedCapacity)) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_CONSUMED_CAPACITY,\n response.data.ConsumedCapacity.map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\n );\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"dynamodb.js","sourceRoot":"","sources":["../../../src/services/dynamodb.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA4D;AAE5D,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,CAAC,iBAAoC;;QACrD,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,y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,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;AAvND,4DAuNC","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, 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(normalizedRequest: NormalizedRequest): 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 [SemanticAttributes.DB_STATEMENT]: JSON.stringify(\n normalizedRequest.commandInput\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 const operation = response.request.commandName;\n\n if (operation === 'BatchGetItem') {\n if (Array.isArray(response.data?.ConsumedCapacity)) {\n span.setAttribute(\n SemanticAttributes.AWS_DYNAMODB_CONSUMED_CAPACITY,\n response.data.ConsumedCapacity.map(\n (x: { [DictionaryKey: string]: any }) => JSON.stringify(x)\n )\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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.34.3";
1
+ export declare const VERSION = "0.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.34.3';
20
+ exports.VERSION = '0.35.0';
21
21
  //# 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,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.34.3';\n"]}
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.35.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-aws-sdk",
3
- "version": "0.34.3",
3
+ "version": "0.35.0",
4
4
  "description": "OpenTelemetry automatic instrumentation for the `aws-sdk` package",
5
5
  "keywords": [
6
6
  "aws",
@@ -47,9 +47,10 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@opentelemetry/core": "^1.8.0",
50
- "@opentelemetry/instrumentation": "^0.40.0",
51
- "@opentelemetry/propagation-utils": "^0.29.5",
52
- "@opentelemetry/semantic-conventions": "^1.0.0"
50
+ "@opentelemetry/instrumentation": "^0.41.0",
51
+ "@opentelemetry/propagation-utils": "^0.30.0",
52
+ "@opentelemetry/semantic-conventions": "^1.0.0",
53
+ "tslib": "^2.3.1"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@aws-sdk/client-dynamodb": "3.85.0",
@@ -59,7 +60,7 @@
59
60
  "@aws-sdk/client-sqs": "3.85.0",
60
61
  "@aws-sdk/types": "3.78.0",
61
62
  "@opentelemetry/api": "^1.3.0",
62
- "@opentelemetry/contrib-test-utils": "^0.33.4",
63
+ "@opentelemetry/contrib-test-utils": "^0.34.0",
63
64
  "@opentelemetry/sdk-trace-base": "^1.8.0",
64
65
  "@types/mocha": "8.2.3",
65
66
  "@types/node": "18.11.7",
@@ -79,5 +80,5 @@
79
80
  "engines": {
80
81
  "node": ">=14"
81
82
  },
82
- "gitHead": "efdfc727a49090accee7fea8ff93011b6b84c1e4"
83
+ "gitHead": "f81f8a76a8f0af2101c62dbc73cde442f875d833"
83
84
  }