@opentelemetry/instrumentation-mongodb 0.42.0 → 0.44.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.
package/LICENSE CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright [2022] OpenTelemetry Authors
189
+ Copyright [yyyy] [name of copyright owner]
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -55,6 +55,22 @@ Mongodb instrumentation has few options available to choose from. You can set th
55
55
  | `responseHook` | `MongoDBInstrumentationExecutionResponseHook` (function) | Function for adding custom attributes from db response |
56
56
  | `dbStatementSerializer` | `DbStatementSerializer` (function) | Custom serializer function for the db.statement tag |
57
57
 
58
+ ## Semantic Conventions
59
+
60
+ This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which implements Semantic Convention [Version 1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md)
61
+
62
+ Attributes collected:
63
+
64
+ | Attribute | Short Description |
65
+ | ----------------------- | ------------------------------------------------------------------------------ |
66
+ | `db.system` | An identifier for the database management system (DBMS) product being used. |
67
+ | `db.connection_string` | The connection string used to connect to the database. |
68
+ | `db.name` | This attribute is used to report the name of the database being accessed. |
69
+ | `db.operation` | The name of the operation being executed. |
70
+ | `db.mongodb.collection` | The collection being accessed within the database stated in `db.name`. |
71
+ | `net.peer.name` | Remote hostname or similar. |
72
+ | `net.peer.port` | Remote port number. |
73
+
58
74
  ## Useful links
59
75
 
60
76
  - For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
@@ -2,12 +2,12 @@ import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opent
2
2
  import { MongoDBInstrumentationConfig } from './types';
3
3
  /** mongodb instrumentation plugin for OpenTelemetry */
4
4
  export declare class MongoDBInstrumentation extends InstrumentationBase {
5
- protected _config: MongoDBInstrumentationConfig;
6
5
  private _connectionsUsage;
7
6
  private _poolName;
8
- constructor(_config?: MongoDBInstrumentationConfig);
7
+ protected _config: MongoDBInstrumentationConfig;
8
+ constructor(config?: MongoDBInstrumentationConfig);
9
9
  _updateMetricInstruments(): void;
10
- init(): InstrumentationNodeModuleDefinition<any>[];
10
+ init(): InstrumentationNodeModuleDefinition[];
11
11
  private _getV3ConnectionPatches;
12
12
  private _getV4SessionsPatches;
13
13
  private _getV4AcquireCommand;
@@ -23,9 +23,8 @@ const internal_types_1 = require("./internal-types");
23
23
  const version_1 = require("./version");
24
24
  /** mongodb instrumentation plugin for OpenTelemetry */
25
25
  class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
26
- constructor(_config = {}) {
27
- super('@opentelemetry/instrumentation-mongodb', version_1.VERSION, _config);
28
- this._config = _config;
26
+ constructor(config = {}) {
27
+ super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, config);
29
28
  }
30
29
  _updateMetricInstruments() {
31
30
  this._connectionsUsage = this.meter.createUpDownCounter('db.client.connections.usage', {
@@ -54,8 +53,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
54
53
  }
55
54
  _getV3ConnectionPatches() {
56
55
  return {
57
- v3PatchConnection: (moduleExports, moduleVersion) => {
58
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
56
+ v3PatchConnection: (moduleExports) => {
59
57
  // patch insert operation
60
58
  if ((0, instrumentation_1.isWrapped)(moduleExports.insert)) {
61
59
  this._unwrap(moduleExports, 'insert');
@@ -88,10 +86,9 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
88
86
  this._wrap(moduleExports, 'getMore', this._getV3PatchCursor());
89
87
  return moduleExports;
90
88
  },
91
- v3UnpatchConnection: (moduleExports, moduleVersion) => {
89
+ v3UnpatchConnection: (moduleExports) => {
92
90
  if (moduleExports === undefined)
93
91
  return;
94
- api_1.diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);
95
92
  this._unwrap(moduleExports, 'insert');
96
93
  this._unwrap(moduleExports, 'remove');
97
94
  this._unwrap(moduleExports, 'update');
@@ -103,8 +100,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
103
100
  }
104
101
  _getV4SessionsPatches() {
105
102
  return {
106
- v4PatchSessions: (moduleExports, moduleVersion) => {
107
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
103
+ v4PatchSessions: (moduleExports) => {
108
104
  if ((0, instrumentation_1.isWrapped)(moduleExports.acquire)) {
109
105
  this._unwrap(moduleExports, 'acquire');
110
106
  }
@@ -115,8 +111,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
115
111
  this._wrap(moduleExports.ServerSessionPool.prototype, 'release', this._getV4ReleaseCommand());
116
112
  return moduleExports;
117
113
  },
118
- v4UnpatchSessions: (moduleExports, moduleVersion) => {
119
- api_1.diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);
114
+ v4UnpatchSessions: (moduleExports) => {
120
115
  if (moduleExports === undefined)
121
116
  return;
122
117
  if ((0, instrumentation_1.isWrapped)(moduleExports.acquire)) {
@@ -176,8 +171,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
176
171
  }
177
172
  _getV4ConnectionPoolPatches() {
178
173
  return {
179
- v4PatchConnectionPool: (moduleExports, moduleVersion) => {
180
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
174
+ v4PatchConnectionPool: (moduleExports) => {
181
175
  const poolPrototype = moduleExports.ConnectionPool.prototype;
182
176
  if ((0, instrumentation_1.isWrapped)(poolPrototype.checkOut)) {
183
177
  this._unwrap(poolPrototype, 'checkOut');
@@ -185,8 +179,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
185
179
  this._wrap(poolPrototype, 'checkOut', this._getV4ConnectionPoolCheckOut());
186
180
  return moduleExports;
187
181
  },
188
- v4UnpatchConnectionPool: (moduleExports, moduleVersion) => {
189
- api_1.diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);
182
+ v4UnpatchConnectionPool: (moduleExports) => {
190
183
  if (moduleExports === undefined)
191
184
  return;
192
185
  this._unwrap(moduleExports.ConnectionPool.prototype, 'checkOut');
@@ -195,16 +188,14 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
195
188
  }
196
189
  _getV4ConnectPatches() {
197
190
  return {
198
- v4PatchConnect: (moduleExports, moduleVersion) => {
199
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
191
+ v4PatchConnect: (moduleExports) => {
200
192
  if ((0, instrumentation_1.isWrapped)(moduleExports.connect)) {
201
193
  this._unwrap(moduleExports, 'connect');
202
194
  }
203
195
  this._wrap(moduleExports, 'connect', this._getV4ConnectCommand());
204
196
  return moduleExports;
205
197
  },
206
- v4UnpatchConnect: (moduleExports, moduleVersion) => {
207
- api_1.diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);
198
+ v4UnpatchConnect: (moduleExports) => {
208
199
  if (moduleExports === undefined)
209
200
  return;
210
201
  this._unwrap(moduleExports, 'connect');
@@ -252,8 +243,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
252
243
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
253
244
  _getV4ConnectionPatches() {
254
245
  return {
255
- v4PatchConnectionCallback: (moduleExports, moduleVersion) => {
256
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
246
+ v4PatchConnectionCallback: (moduleExports) => {
257
247
  // patch insert operation
258
248
  if ((0, instrumentation_1.isWrapped)(moduleExports.Connection.prototype.command)) {
259
249
  this._unwrap(moduleExports.Connection.prototype, 'command');
@@ -261,8 +251,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
261
251
  this._wrap(moduleExports.Connection.prototype, 'command', this._getV4PatchCommandCallback());
262
252
  return moduleExports;
263
253
  },
264
- v4PatchConnectionPromise: (moduleExports, moduleVersion) => {
265
- api_1.diag.debug(`Applying patch for mongodb@${moduleVersion}`);
254
+ v4PatchConnectionPromise: (moduleExports) => {
266
255
  // patch insert operation
267
256
  if ((0, instrumentation_1.isWrapped)(moduleExports.Connection.prototype.command)) {
268
257
  this._unwrap(moduleExports.Connection.prototype, 'command');
@@ -270,10 +259,9 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
270
259
  this._wrap(moduleExports.Connection.prototype, 'command', this._getV4PatchCommandPromise());
271
260
  return moduleExports;
272
261
  },
273
- v4UnpatchConnection: (moduleExports, moduleVersion) => {
262
+ v4UnpatchConnection: (moduleExports) => {
274
263
  if (moduleExports === undefined)
275
264
  return;
276
- api_1.diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);
277
265
  this._unwrap(moduleExports.Connection.prototype, 'command');
278
266
  },
279
267
  };
@@ -547,17 +535,17 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
547
535
  _addAllSpanAttributes(span, dbName, dbCollection, host, port, commandObj, operation) {
548
536
  // add database related attributes
549
537
  span.setAttributes({
550
- [semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.MONGODB,
551
- [semantic_conventions_1.SemanticAttributes.DB_NAME]: dbName,
552
- [semantic_conventions_1.SemanticAttributes.DB_MONGODB_COLLECTION]: dbCollection,
553
- [semantic_conventions_1.SemanticAttributes.DB_OPERATION]: operation,
554
- [semantic_conventions_1.SemanticAttributes.DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,
538
+ [semantic_conventions_1.SEMATTRS_DB_SYSTEM]: semantic_conventions_1.DBSYSTEMVALUES_MONGODB,
539
+ [semantic_conventions_1.SEMATTRS_DB_NAME]: dbName,
540
+ [semantic_conventions_1.SEMATTRS_DB_MONGODB_COLLECTION]: dbCollection,
541
+ [semantic_conventions_1.SEMATTRS_DB_OPERATION]: operation,
542
+ [semantic_conventions_1.SEMATTRS_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,
555
543
  });
556
544
  if (host && port) {
557
- span.setAttribute(semantic_conventions_1.SemanticAttributes.NET_PEER_NAME, host);
545
+ span.setAttribute(semantic_conventions_1.SEMATTRS_NET_PEER_NAME, host);
558
546
  const portNumber = parseInt(port, 10);
559
547
  if (!isNaN(portNumber)) {
560
- span.setAttribute(semantic_conventions_1.SemanticAttributes.NET_PEER_PORT, portNumber);
548
+ span.setAttribute(semantic_conventions_1.SEMATTRS_NET_PEER_PORT, portNumber);
561
549
  }
562
550
  }
563
551
  if (!commandObj)
@@ -567,7 +555,7 @@ class MongoDBInstrumentation extends instrumentation_1.InstrumentationBase {
567
555
  : this._defaultDbStatementSerializer.bind(this);
568
556
  (0, instrumentation_1.safeExecuteInTheMiddle)(() => {
569
557
  const query = dbStatementSerializer(commandObj);
570
- span.setAttribute(semantic_conventions_1.SemanticAttributes.DB_STATEMENT, query);
558
+ span.setAttribute(semantic_conventions_1.SEMATTRS_DB_STATEMENT, query);
571
559
  }, err => {
572
560
  if (err) {
573
561
  this._diag.error('Error running dbStatementSerializer hook', err);
@@ -1 +1 @@
1
- {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAO4B;AAC5B,oEAMwC;AACxC,8EAG6C;AAE7C,qDAS0B;AAE1B,uCAAoC;AAGpC,uDAAuD;AACvD,MAAa,sBAAuB,SAAQ,qCAAmB;IAI7D,YAA+B,UAAwC,EAAE;QACvE,KAAK,CAAC,wCAAwC,EAAE,iBAAO,EAAE,OAAO,CAAC,CAAC;QADrC,YAAO,GAAP,OAAO,CAAmC;IAEzE,CAAC;IAEQ,wBAAwB;QAC/B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CACrD,6BAA6B,EAC7B;YACE,WAAW,EACT,yFAAyF;YAC3F,IAAI,EAAE,cAAc;SACrB,CACF,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,EACJ,iBAAiB,EA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iBACtD;gBACD,IAAI,CAAC,GAAG,EAAE,CAAC;aACZ;YAED,OAAO,aAAO,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;gBACtC,IAAI,WAAW,KAAK,aAAa,EAAE;oBACjC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACxC,KAAK,EAAE,MAAM;wBACb,WAAW,EAAE,eAAe,CAAC,SAAS;qBACvC,CAAC,CAAC;iBACJ;gBACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IACO,WAAW,CAAC,OAAY;;QAC9B,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC;QACvC,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC;QACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;QAChC,MAAM,QAAQ,GAAG,aAAa,IAAI,IAAI,IAAI,IAAI,QAAQ,EAAE,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;CACF;AAt8BD,wDAs8BC","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 context,\n diag,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n DbSystemValues,\n SemanticAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport { MongoDBInstrumentationConfig, CommandResult } from './types';\nimport {\n CursorState,\n ServerSession,\n MongodbCommandType,\n MongoInternalCommand,\n MongoInternalTopology,\n WireProtocolInternal,\n V4Connection,\n V4ConnectionPool,\n} from './internal-types';\nimport { V4Connect, V4Session } from './internal-types';\nimport { VERSION } from './version';\nimport { UpDownCounter } from '@opentelemetry/api';\n\n/** mongodb instrumentation plugin for OpenTelemetry */\nexport class MongoDBInstrumentation extends InstrumentationBase {\n private _connectionsUsage!: UpDownCounter;\n private _poolName!: string;\n\n constructor(protected override _config: MongoDBInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-mongodb', VERSION, _config);\n }\n\n override _updateMetricInstruments() {\n this._connectionsUsage = this.meter.createUpDownCounter(\n 'db.client.connections.usage',\n {\n description:\n 'The number of connections that are currently in state described by the state attribute.',\n unit: '{connection}',\n }\n );\n }\n\n init() {\n const {\n v3PatchConnection: v3PatchConnection,\n v3UnpatchConnection: v3UnpatchConnection,\n } = this._getV3ConnectionPatches();\n\n const { v4PatchConnect, v4UnpatchConnect } = this._getV4ConnectPatches();\n const {\n v4PatchConnectionCallback,\n v4PatchConnectionPromise,\n v4UnpatchConnection,\n } = this._getV4ConnectionPatches();\n const { v4PatchConnectionPool, v4UnpatchConnectionPool } =\n this._getV4ConnectionPoolPatches();\n const { v4PatchSessions, v4UnpatchSessions } = this._getV4SessionsPatches();\n\n return [\n new InstrumentationNodeModuleDefinition<any>(\n 'mongodb',\n ['>=3.3 <4'],\n undefined,\n undefined,\n [\n new InstrumentationNodeModuleFile<WireProtocolInternal>(\n 'mongodb/lib/core/wireprotocol/index.js',\n ['>=3.3 <4'],\n v3PatchConnection,\n v3UnpatchConnection\n ),\n ]\n ),\n new InstrumentationNodeModuleDefinition<any>(\n 'mongodb',\n ['4.*', '5.*', '6.*'],\n undefined,\n undefined,\n [\n new InstrumentationNodeModuleFile<V4Connection>(\n 'mongodb/lib/cmap/connection.js',\n ['4.*', '5.*', '>=6 <6.4'],\n v4PatchConnectionCallback,\n v4UnpatchConnection\n ),\n new InstrumentationNodeModuleFile<V4Connection>(\n 'mongodb/lib/cmap/connection.js',\n ['>=6.4'],\n v4PatchConnectionPromise,\n v4UnpatchConnection\n ),\n new InstrumentationNodeModuleFile<V4ConnectionPool>(\n 'mongodb/lib/cmap/connection_pool.js',\n ['4.*', '5.*', '>=6 <6.4'],\n v4PatchConnectionPool,\n v4UnpatchConnectionPool\n ),\n new InstrumentationNodeModuleFile<V4Connect>(\n 'mongodb/lib/cmap/connect.js',\n ['4.*', '5.*', '6.*'],\n v4PatchConnect,\n v4UnpatchConnect\n ),\n new InstrumentationNodeModuleFile<V4Session>(\n 'mongodb/lib/sessions.js',\n ['4.*', '5.*', '6.*'],\n v4PatchSessions,\n v4UnpatchSessions\n ),\n ]\n ),\n ];\n }\n\n private _getV3ConnectionPatches<T extends WireProtocolInternal>() {\n return {\n v3PatchConnection: (moduleExports: T, moduleVersion?: string) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n // patch insert operation\n if (isWrapped(moduleExports.insert)) {\n this._unwrap(moduleExports, 'insert');\n }\n this._wrap(\n moduleExports,\n 'insert',\n this._getV3PatchOperation('insert')\n );\n // patch remove operation\n if (isWrapped(moduleExports.remove)) {\n this._unwrap(moduleExports, 'remove');\n }\n this._wrap(\n moduleExports,\n 'remove',\n this._getV3PatchOperation('remove')\n );\n // patch update operation\n if (isWrapped(moduleExports.update)) {\n this._unwrap(moduleExports, 'update');\n }\n this._wrap(\n moduleExports,\n 'update',\n this._getV3PatchOperation('update')\n );\n // patch other command\n if (isWrapped(moduleExports.command)) {\n this._unwrap(moduleExports, 'command');\n }\n this._wrap(moduleExports, 'command', this._getV3PatchCommand());\n // patch query\n if (isWrapped(moduleExports.query)) {\n this._unwrap(moduleExports, 'query');\n }\n this._wrap(moduleExports, 'query', this._getV3PatchFind());\n // patch get more operation on cursor\n if (isWrapped(moduleExports.getMore)) {\n this._unwrap(moduleExports, 'getMore');\n }\n this._wrap(moduleExports, 'getMore', this._getV3PatchCursor());\n return moduleExports;\n },\n v3UnpatchConnection: (moduleExports?: T, moduleVersion?: string) => {\n if (moduleExports === undefined) return;\n diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);\n this._unwrap(moduleExports, 'insert');\n this._unwrap(moduleExports, 'remove');\n this._unwrap(moduleExports, 'update');\n this._unwrap(moduleExports, 'command');\n this._unwrap(moduleExports, 'query');\n this._unwrap(moduleExports, 'getMore');\n },\n };\n }\n\n private _getV4SessionsPatches<T extends V4Session>() {\n return {\n v4PatchSessions: (moduleExports: any, moduleVersion?: string) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n if (isWrapped(moduleExports.acquire)) {\n this._unwrap(moduleExports, 'acquire');\n }\n this._wrap(\n moduleExports.ServerSessionPool.prototype,\n 'acquire',\n this._getV4AcquireCommand()\n );\n\n if (isWrapped(moduleExports.release)) {\n this._unwrap(moduleExports, 'release');\n }\n this._wrap(\n moduleExports.ServerSessionPool.prototype,\n 'release',\n this._getV4ReleaseCommand()\n );\n return moduleExports;\n },\n v4UnpatchSessions: (moduleExports?: T, moduleVersion?: string) => {\n diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);\n if (moduleExports === undefined) return;\n if (isWrapped(moduleExports.acquire)) {\n this._unwrap(moduleExports, 'acquire');\n }\n if (isWrapped(moduleExports.release)) {\n this._unwrap(moduleExports, 'release');\n }\n },\n };\n }\n\n private _getV4AcquireCommand() {\n const instrumentation = this;\n return (original: V4Session['acquire']) => {\n return function patchAcquire(this: any) {\n const nSessionsBeforeAcquire = this.sessions.length;\n const session = original.call(this);\n const nSessionsAfterAcquire = this.sessions.length;\n\n if (nSessionsBeforeAcquire === nSessionsAfterAcquire) {\n //no session in the pool. a new session was created and used\n instrumentation._connectionsUsage.add(1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n } else if (nSessionsBeforeAcquire - 1 === nSessionsAfterAcquire) {\n //a session was already in the pool. remove it from the pool and use it.\n instrumentation._connectionsUsage.add(-1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n instrumentation._connectionsUsage.add(1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n }\n return session;\n };\n };\n }\n\n private _getV4ReleaseCommand() {\n const instrumentation = this;\n return (original: V4Session['release']) => {\n return function patchRelease(this: any, session: ServerSession) {\n const cmdPromise = original.call(this, session);\n\n instrumentation._connectionsUsage.add(-1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n instrumentation._connectionsUsage.add(1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n return cmdPromise;\n };\n };\n }\n\n private _getV4ConnectionPoolPatches<T extends V4ConnectionPool>() {\n return {\n v4PatchConnectionPool: (moduleExports: any, moduleVersion?: string) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n const poolPrototype = moduleExports.ConnectionPool.prototype;\n\n if (isWrapped(poolPrototype.checkOut)) {\n this._unwrap(poolPrototype, 'checkOut');\n }\n\n this._wrap(\n poolPrototype,\n 'checkOut',\n this._getV4ConnectionPoolCheckOut()\n );\n return moduleExports;\n },\n v4UnpatchConnectionPool: (\n moduleExports?: any,\n moduleVersion?: string\n ) => {\n diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);\n if (moduleExports === undefined) return;\n\n this._unwrap(moduleExports.ConnectionPool.prototype, 'checkOut');\n },\n };\n }\n\n private _getV4ConnectPatches<T extends V4Connect>() {\n return {\n v4PatchConnect: (moduleExports: any, moduleVersion?: string) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n if (isWrapped(moduleExports.connect)) {\n this._unwrap(moduleExports, 'connect');\n }\n\n this._wrap(moduleExports, 'connect', this._getV4ConnectCommand());\n return moduleExports;\n },\n v4UnpatchConnect: (moduleExports?: T, moduleVersion?: string) => {\n diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);\n if (moduleExports === undefined) return;\n\n this._unwrap(moduleExports, 'connect');\n },\n };\n }\n\n // This patch will become unnecessary once\n // https://jira.mongodb.org/browse/NODE-5639 is done.\n private _getV4ConnectionPoolCheckOut() {\n return (original: V4ConnectionPool['checkOut']) => {\n return function patchedCheckout(this: unknown, callback: any) {\n const patchedCallback = context.bind(context.active(), callback);\n return original.call(this, patchedCallback);\n };\n };\n }\n\n private _getV4ConnectCommand() {\n const instrumentation = this;\n\n return (\n original: V4Connect['connectCallback'] | V4Connect['connectPromise']\n ) => {\n return function patchedConnect(\n this: unknown,\n options: any,\n callback: any\n ) {\n // from v6.4 `connect` method only accepts an options param and returns a promise\n // with the connection\n if (original.length === 1) {\n const result = (original as V4Connect['connectPromise']).call(\n this,\n options\n );\n if (result && typeof result.then === 'function') {\n result.then(\n () => instrumentation.setPoolName(options),\n // this handler is set to pass the lint rules\n () => undefined\n );\n }\n return result;\n }\n\n // Earlier versions expects a callback param and return void\n const patchedCallback = function (err: any, conn: any) {\n if (err || !conn) {\n callback(err, conn);\n return;\n }\n instrumentation.setPoolName(options);\n callback(err, conn);\n };\n\n return (original as V4Connect['connectCallback']).call(\n this,\n options,\n patchedCallback\n );\n };\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private _getV4ConnectionPatches<T extends V4Connection>() {\n return {\n v4PatchConnectionCallback: (\n moduleExports: any,\n moduleVersion?: string\n ) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n // patch insert operation\n if (isWrapped(moduleExports.Connection.prototype.command)) {\n this._unwrap(moduleExports.Connection.prototype, 'command');\n }\n\n this._wrap(\n moduleExports.Connection.prototype,\n 'command',\n this._getV4PatchCommandCallback()\n );\n return moduleExports;\n },\n v4PatchConnectionPromise: (\n moduleExports: any,\n moduleVersion?: string\n ) => {\n diag.debug(`Applying patch for mongodb@${moduleVersion}`);\n // patch insert operation\n if (isWrapped(moduleExports.Connection.prototype.command)) {\n this._unwrap(moduleExports.Connection.prototype, 'command');\n }\n\n this._wrap(\n moduleExports.Connection.prototype,\n 'command',\n this._getV4PatchCommandPromise()\n );\n return moduleExports;\n },\n v4UnpatchConnection: (moduleExports?: any, moduleVersion?: string) => {\n if (moduleExports === undefined) return;\n diag.debug(`Removing internal patch for mongodb@${moduleVersion}`);\n this._unwrap(moduleExports.Connection.prototype, 'command');\n },\n };\n }\n\n /** Creates spans for common operations */\n private _getV3PatchOperation(operationName: 'insert' | 'update' | 'remove') {\n const instrumentation = this;\n return (original: WireProtocolInternal[typeof operationName]) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n ops: unknown[],\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof ops !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, ops, options);\n } else {\n return original.call(this, server, ns, ops, options, callback);\n }\n }\n const span = instrumentation.tracer.startSpan(\n `mongodb.${operationName}`,\n {\n kind: SpanKind.CLIENT,\n }\n );\n\n instrumentation._populateV3Attributes(\n span,\n ns,\n server,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ops[0] as any,\n operationName\n );\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(this, server, ns, ops, patchedCallback);\n } else {\n return original.call(this, server, ns, ops, options, patchedCallback);\n }\n };\n };\n }\n\n /** Creates spans for command operation */\n private _getV3PatchCommand() {\n const instrumentation = this;\n return (original: WireProtocolInternal['command']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cmd: MongoInternalCommand,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, options);\n } else {\n return original.call(this, server, ns, cmd, options, callback);\n }\n }\n const commandType = MongoDBInstrumentation._getCommandType(cmd);\n const type =\n commandType === MongodbCommandType.UNKNOWN ? 'command' : commandType;\n const span = instrumentation.tracer.startSpan(`mongodb.${type}`, {\n kind: SpanKind.CLIENT,\n });\n const operation =\n commandType === MongodbCommandType.UNKNOWN ? undefined : commandType;\n instrumentation._populateV3Attributes(span, ns, server, cmd, operation);\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, patchedCallback);\n } else {\n return original.call(this, server, ns, cmd, options, patchedCallback);\n }\n };\n };\n }\n\n /** Creates spans for command operation */\n private _getV4PatchCommandCallback() {\n const instrumentation = this;\n return (original: V4Connection['commandCallback']) => {\n return function patchedV4ServerCommand(\n this: any,\n ns: any,\n cmd: any,\n options: undefined | unknown,\n callback: any\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler = callback;\n const commandType = Object.keys(cmd)[0];\n\n if (\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object' ||\n cmd.ismaster ||\n cmd.hello\n ) {\n return original.call(this, ns, cmd, options, callback);\n }\n\n let span = undefined;\n if (currentSpan) {\n span = instrumentation.tracer.startSpan(`mongodb.${commandType}`, {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV4Attributes(\n span,\n this,\n ns,\n cmd,\n commandType\n );\n }\n const patchedCallback = instrumentation._patchEnd(\n span,\n resultHandler,\n this.id,\n commandType\n );\n\n return original.call(this, ns, cmd, options, patchedCallback);\n };\n };\n }\n\n private _getV4PatchCommandPromise() {\n const instrumentation = this;\n return (original: V4Connection['commandPromise']) => {\n return function patchedV4ServerCommand(\n this: any,\n ns: any,\n cmd: any,\n options: undefined | unknown\n ) {\n const currentSpan = trace.getSpan(context.active());\n const commandType = Object.keys(cmd)[0];\n const resultHandler = () => undefined;\n\n if (typeof cmd !== 'object' || cmd.ismaster || cmd.hello) {\n return original.call(this, ns, cmd, options);\n }\n\n let span = undefined;\n if (currentSpan) {\n span = instrumentation.tracer.startSpan(`mongodb.${commandType}`, {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV4Attributes(\n span,\n this,\n ns,\n cmd,\n commandType\n );\n }\n\n const patchedCallback = instrumentation._patchEnd(\n span,\n resultHandler,\n this.id,\n commandType\n );\n\n const result = original.call(this, ns, cmd, options);\n result.then(\n (res: any) => patchedCallback(null, res),\n (err: any) => patchedCallback(err)\n );\n\n return result;\n };\n };\n }\n\n /** Creates spans for find operation */\n private _getV3PatchFind() {\n const instrumentation = this;\n return (original: WireProtocolInternal['query']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cmd: MongoInternalCommand,\n cursorState: CursorState,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, cursorState, options);\n } else {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n options,\n callback\n );\n }\n }\n const span = instrumentation.tracer.startSpan('mongodb.find', {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV3Attributes(span, ns, server, cmd, 'find');\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n patchedCallback\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n options,\n patchedCallback\n );\n }\n };\n };\n }\n\n /** Creates spans for find operation */\n private _getV3PatchCursor() {\n const instrumentation = this;\n return (original: WireProtocolInternal['getMore']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cursorState: CursorState,\n batchSize: number,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (!currentSpan || typeof resultHandler !== 'function') {\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options,\n callback\n );\n }\n }\n const span = instrumentation.tracer.startSpan('mongodb.getMore', {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV3Attributes(\n span,\n ns,\n server,\n cursorState.cmd,\n 'getMore'\n );\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n patchedCallback\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options,\n patchedCallback\n );\n }\n };\n };\n }\n\n /**\n * Get the mongodb command type from the object.\n * @param command Internal mongodb command object\n */\n private static _getCommandType(\n command: MongoInternalCommand\n ): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n }\n\n /**\n * Populate span's attributes by fetching related metadata from the context\n * @param span span to add attributes to\n * @param connectionCtx mongodb internal connection context\n * @param ns mongodb namespace\n * @param command mongodb internal representation of a command\n */\n private _populateV4Attributes(\n span: Span,\n connectionCtx: any,\n ns: any,\n command?: any,\n operation?: string\n ) {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts =\n typeof connectionCtx.address === 'string'\n ? connectionCtx.address.split(':')\n : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n // capture parameters within the query as well if enhancedDatabaseReporting is enabled.\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n this._addAllSpanAttributes(\n span,\n ns.db,\n ns.collection,\n host,\n port,\n commandObj,\n operation\n );\n }\n\n /**\n * Populate span's attributes by fetching related metadata from the context\n * @param span span to add attributes to\n * @param ns mongodb namespace\n * @param topology mongodb internal representation of the network topology\n * @param command mongodb internal representation of a command\n */\n private _populateV3Attributes(\n span: Span,\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined\n ) {\n // add network attributes to determine the remote server\n let host: undefined | string;\n let port: undefined | string;\n if (topology && topology.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n // capture parameters within the query as well if enhancedDatabaseReporting is enabled.\n const commandObj = command?.query ?? command?.q ?? command;\n\n this._addAllSpanAttributes(\n span,\n dbName,\n dbCollection,\n host,\n port,\n commandObj,\n operation\n );\n }\n\n private _addAllSpanAttributes(\n span: Span,\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined\n ) {\n // add database related attributes\n span.setAttributes({\n [SemanticAttributes.DB_SYSTEM]: DbSystemValues.MONGODB,\n [SemanticAttributes.DB_NAME]: dbName,\n [SemanticAttributes.DB_MONGODB_COLLECTION]: dbCollection,\n [SemanticAttributes.DB_OPERATION]: operation,\n [SemanticAttributes.DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n });\n\n if (host && port) {\n span.setAttribute(SemanticAttributes.NET_PEER_NAME, host);\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n span.setAttribute(SemanticAttributes.NET_PEER_PORT, portNumber);\n }\n }\n if (!commandObj) return;\n const dbStatementSerializer =\n typeof this._config.dbStatementSerializer === 'function'\n ? this._config.dbStatementSerializer\n : this._defaultDbStatementSerializer.bind(this);\n\n safeExecuteInTheMiddle(\n () => {\n const query = dbStatementSerializer(commandObj);\n span.setAttribute(SemanticAttributes.DB_STATEMENT, query);\n },\n err => {\n if (err) {\n this._diag.error('Error running dbStatementSerializer hook', err);\n }\n },\n true\n );\n }\n\n private _defaultDbStatementSerializer(commandObj: Record<string, unknown>) {\n const enhancedDbReporting = !!this._config?.enhancedDatabaseReporting;\n const resultObj = enhancedDbReporting\n ? commandObj\n : Object.keys(commandObj).reduce((obj, key) => {\n obj[key] = '?';\n return obj;\n }, {} as { [key: string]: unknown });\n return JSON.stringify(resultObj);\n }\n\n /**\n * Triggers the response hook in case it is defined.\n * @param span The span to add the results to.\n * @param result The command result\n */\n private _handleExecutionResult(span: Span, result: CommandResult) {\n const config: MongoDBInstrumentationConfig = this.getConfig();\n if (typeof config.responseHook === 'function') {\n safeExecuteInTheMiddle(\n () => {\n config.responseHook!(span, { data: result });\n },\n err => {\n if (err) {\n this._diag.error('Error running response hook', err);\n }\n },\n true\n );\n }\n }\n\n /**\n * Ends a created span.\n * @param span The created span to end.\n * @param resultHandler A callback function.\n * @param connectionId: The connection ID of the Command response.\n */\n private _patchEnd(\n span: Span | undefined,\n resultHandler: Function,\n connectionId?: number,\n commandType?: string\n ): Function {\n // mongodb is using \"tick\" when calling a callback, this way the context\n // in final callback (resultHandler) is lost\n const activeContext = context.active();\n const instrumentation = this;\n return function patchedEnd(this: {}, ...args: unknown[]) {\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span?.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n } else {\n const result = args[1] as CommandResult;\n instrumentation._handleExecutionResult(span, result);\n }\n span.end();\n }\n\n return context.with(activeContext, () => {\n if (commandType === 'endSessions') {\n instrumentation._connectionsUsage.add(-1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n }\n return resultHandler.apply(this, args);\n });\n };\n }\n private setPoolName(options: any) {\n const host = options.hostAddress?.host;\n const port = options.hostAddress?.port;\n const database = options.dbName;\n const poolName = `mongodb://${host}:${port}/${database}`;\n this._poolName = poolName;\n }\n}\n"]}
1
+ {"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAC5B,oEAMwC;AACxC,8EAU6C;AAE7C,qDAS0B;AAE1B,uCAA0D;AAG1D,uDAAuD;AACvD,MAAa,sBAAuB,SAAQ,qCAAmB;IAM7D,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAEQ,wBAAwB;QAC/B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CACrD,6BAA6B,EAC7B;YACE,WAAW,EACT,yFAAyF;YAC3F,IAAI,EAAE,cAAc;SACrB,CACF,CAAC;IACJ,CAAC;IAED,IAAI;QACF,MAAM,EACJ,iBAAiB,EAAE,iBAAiB,EACpC,mBAAmB,EAAE,mBAAmB,GACzC,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAEnC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACzE,MAAM,EACJ,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,GACpB,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAC;QACnC,MAAM,EAAE,qBAAqB,EAAE,u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E,CAAC;aACZ;YAED,OAAO,aAAO,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;gBACtC,IAAI,WAAW,KAAK,aAAa,EAAE;oBACjC,eAAe,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;wBACxC,KAAK,EAAE,MAAM;wBACb,WAAW,EAAE,eAAe,CAAC,SAAS;qBACvC,CAAC,CAAC;iBACJ;gBACD,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IACO,WAAW,CAAC,OAAY;;QAC9B,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC;QACvC,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC;QACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;QAChC,MAAM,QAAQ,GAAG,aAAa,IAAI,IAAI,IAAI,IAAI,QAAQ,EAAE,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;CACF;AAp7BD,wDAo7BC","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 context,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n DBSYSTEMVALUES_MONGODB,\n SEMATTRS_DB_CONNECTION_STRING,\n SEMATTRS_DB_MONGODB_COLLECTION,\n SEMATTRS_DB_NAME,\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport { MongoDBInstrumentationConfig, CommandResult } from './types';\nimport {\n CursorState,\n ServerSession,\n MongodbCommandType,\n MongoInternalCommand,\n MongoInternalTopology,\n WireProtocolInternal,\n V4Connection,\n V4ConnectionPool,\n} from './internal-types';\nimport { V4Connect, V4Session } from './internal-types';\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport { UpDownCounter } from '@opentelemetry/api';\n\n/** mongodb instrumentation plugin for OpenTelemetry */\nexport class MongoDBInstrumentation extends InstrumentationBase {\n private _connectionsUsage!: UpDownCounter;\n private _poolName!: string;\n\n protected override _config!: MongoDBInstrumentationConfig;\n\n constructor(config: MongoDBInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n override _updateMetricInstruments() {\n this._connectionsUsage = this.meter.createUpDownCounter(\n 'db.client.connections.usage',\n {\n description:\n 'The number of connections that are currently in state described by the state attribute.',\n unit: '{connection}',\n }\n );\n }\n\n init() {\n const {\n v3PatchConnection: v3PatchConnection,\n v3UnpatchConnection: v3UnpatchConnection,\n } = this._getV3ConnectionPatches();\n\n const { v4PatchConnect, v4UnpatchConnect } = this._getV4ConnectPatches();\n const {\n v4PatchConnectionCallback,\n v4PatchConnectionPromise,\n v4UnpatchConnection,\n } = this._getV4ConnectionPatches();\n const { v4PatchConnectionPool, v4UnpatchConnectionPool } =\n this._getV4ConnectionPoolPatches();\n const { v4PatchSessions, v4UnpatchSessions } = this._getV4SessionsPatches();\n\n return [\n new InstrumentationNodeModuleDefinition(\n 'mongodb',\n ['>=3.3 <4'],\n undefined,\n undefined,\n [\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/core/wireprotocol/index.js',\n ['>=3.3 <4'],\n v3PatchConnection,\n v3UnpatchConnection\n ),\n ]\n ),\n new InstrumentationNodeModuleDefinition(\n 'mongodb',\n ['4.*', '5.*', '6.*'],\n undefined,\n undefined,\n [\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/cmap/connection.js',\n ['4.*', '5.*', '>=6 <6.4'],\n v4PatchConnectionCallback,\n v4UnpatchConnection\n ),\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/cmap/connection.js',\n ['>=6.4'],\n v4PatchConnectionPromise,\n v4UnpatchConnection\n ),\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/cmap/connection_pool.js',\n ['4.*', '5.*', '>=6 <6.4'],\n v4PatchConnectionPool,\n v4UnpatchConnectionPool\n ),\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/cmap/connect.js',\n ['4.*', '5.*', '6.*'],\n v4PatchConnect,\n v4UnpatchConnect\n ),\n new InstrumentationNodeModuleFile(\n 'mongodb/lib/sessions.js',\n ['4.*', '5.*', '6.*'],\n v4PatchSessions,\n v4UnpatchSessions\n ),\n ]\n ),\n ];\n }\n\n private _getV3ConnectionPatches<T extends WireProtocolInternal>() {\n return {\n v3PatchConnection: (moduleExports: T) => {\n // patch insert operation\n if (isWrapped(moduleExports.insert)) {\n this._unwrap(moduleExports, 'insert');\n }\n this._wrap(\n moduleExports,\n 'insert',\n this._getV3PatchOperation('insert')\n );\n // patch remove operation\n if (isWrapped(moduleExports.remove)) {\n this._unwrap(moduleExports, 'remove');\n }\n this._wrap(\n moduleExports,\n 'remove',\n this._getV3PatchOperation('remove')\n );\n // patch update operation\n if (isWrapped(moduleExports.update)) {\n this._unwrap(moduleExports, 'update');\n }\n this._wrap(\n moduleExports,\n 'update',\n this._getV3PatchOperation('update')\n );\n // patch other command\n if (isWrapped(moduleExports.command)) {\n this._unwrap(moduleExports, 'command');\n }\n this._wrap(moduleExports, 'command', this._getV3PatchCommand());\n // patch query\n if (isWrapped(moduleExports.query)) {\n this._unwrap(moduleExports, 'query');\n }\n this._wrap(moduleExports, 'query', this._getV3PatchFind());\n // patch get more operation on cursor\n if (isWrapped(moduleExports.getMore)) {\n this._unwrap(moduleExports, 'getMore');\n }\n this._wrap(moduleExports, 'getMore', this._getV3PatchCursor());\n return moduleExports;\n },\n v3UnpatchConnection: (moduleExports?: T) => {\n if (moduleExports === undefined) return;\n this._unwrap(moduleExports, 'insert');\n this._unwrap(moduleExports, 'remove');\n this._unwrap(moduleExports, 'update');\n this._unwrap(moduleExports, 'command');\n this._unwrap(moduleExports, 'query');\n this._unwrap(moduleExports, 'getMore');\n },\n };\n }\n\n private _getV4SessionsPatches<T extends V4Session>() {\n return {\n v4PatchSessions: (moduleExports: any) => {\n if (isWrapped(moduleExports.acquire)) {\n this._unwrap(moduleExports, 'acquire');\n }\n this._wrap(\n moduleExports.ServerSessionPool.prototype,\n 'acquire',\n this._getV4AcquireCommand()\n );\n\n if (isWrapped(moduleExports.release)) {\n this._unwrap(moduleExports, 'release');\n }\n this._wrap(\n moduleExports.ServerSessionPool.prototype,\n 'release',\n this._getV4ReleaseCommand()\n );\n return moduleExports;\n },\n v4UnpatchSessions: (moduleExports?: T) => {\n if (moduleExports === undefined) return;\n if (isWrapped(moduleExports.acquire)) {\n this._unwrap(moduleExports, 'acquire');\n }\n if (isWrapped(moduleExports.release)) {\n this._unwrap(moduleExports, 'release');\n }\n },\n };\n }\n\n private _getV4AcquireCommand() {\n const instrumentation = this;\n return (original: V4Session['acquire']) => {\n return function patchAcquire(this: any) {\n const nSessionsBeforeAcquire = this.sessions.length;\n const session = original.call(this);\n const nSessionsAfterAcquire = this.sessions.length;\n\n if (nSessionsBeforeAcquire === nSessionsAfterAcquire) {\n //no session in the pool. a new session was created and used\n instrumentation._connectionsUsage.add(1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n } else if (nSessionsBeforeAcquire - 1 === nSessionsAfterAcquire) {\n //a session was already in the pool. remove it from the pool and use it.\n instrumentation._connectionsUsage.add(-1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n instrumentation._connectionsUsage.add(1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n }\n return session;\n };\n };\n }\n\n private _getV4ReleaseCommand() {\n const instrumentation = this;\n return (original: V4Session['release']) => {\n return function patchRelease(this: any, session: ServerSession) {\n const cmdPromise = original.call(this, session);\n\n instrumentation._connectionsUsage.add(-1, {\n state: 'used',\n 'pool.name': instrumentation._poolName,\n });\n instrumentation._connectionsUsage.add(1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n return cmdPromise;\n };\n };\n }\n\n private _getV4ConnectionPoolPatches<T extends V4ConnectionPool>() {\n return {\n v4PatchConnectionPool: (moduleExports: any) => {\n const poolPrototype = moduleExports.ConnectionPool.prototype;\n\n if (isWrapped(poolPrototype.checkOut)) {\n this._unwrap(poolPrototype, 'checkOut');\n }\n\n this._wrap(\n poolPrototype,\n 'checkOut',\n this._getV4ConnectionPoolCheckOut()\n );\n return moduleExports;\n },\n v4UnpatchConnectionPool: (moduleExports?: any) => {\n if (moduleExports === undefined) return;\n\n this._unwrap(moduleExports.ConnectionPool.prototype, 'checkOut');\n },\n };\n }\n\n private _getV4ConnectPatches<T extends V4Connect>() {\n return {\n v4PatchConnect: (moduleExports: any) => {\n if (isWrapped(moduleExports.connect)) {\n this._unwrap(moduleExports, 'connect');\n }\n\n this._wrap(moduleExports, 'connect', this._getV4ConnectCommand());\n return moduleExports;\n },\n v4UnpatchConnect: (moduleExports?: T) => {\n if (moduleExports === undefined) return;\n\n this._unwrap(moduleExports, 'connect');\n },\n };\n }\n\n // This patch will become unnecessary once\n // https://jira.mongodb.org/browse/NODE-5639 is done.\n private _getV4ConnectionPoolCheckOut() {\n return (original: V4ConnectionPool['checkOut']) => {\n return function patchedCheckout(this: unknown, callback: any) {\n const patchedCallback = context.bind(context.active(), callback);\n return original.call(this, patchedCallback);\n };\n };\n }\n\n private _getV4ConnectCommand() {\n const instrumentation = this;\n\n return (\n original: V4Connect['connectCallback'] | V4Connect['connectPromise']\n ) => {\n return function patchedConnect(\n this: unknown,\n options: any,\n callback: any\n ) {\n // from v6.4 `connect` method only accepts an options param and returns a promise\n // with the connection\n if (original.length === 1) {\n const result = (original as V4Connect['connectPromise']).call(\n this,\n options\n );\n if (result && typeof result.then === 'function') {\n result.then(\n () => instrumentation.setPoolName(options),\n // this handler is set to pass the lint rules\n () => undefined\n );\n }\n return result;\n }\n\n // Earlier versions expects a callback param and return void\n const patchedCallback = function (err: any, conn: any) {\n if (err || !conn) {\n callback(err, conn);\n return;\n }\n instrumentation.setPoolName(options);\n callback(err, conn);\n };\n\n return (original as V4Connect['connectCallback']).call(\n this,\n options,\n patchedCallback\n );\n };\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n private _getV4ConnectionPatches<T extends V4Connection>() {\n return {\n v4PatchConnectionCallback: (moduleExports: any) => {\n // patch insert operation\n if (isWrapped(moduleExports.Connection.prototype.command)) {\n this._unwrap(moduleExports.Connection.prototype, 'command');\n }\n\n this._wrap(\n moduleExports.Connection.prototype,\n 'command',\n this._getV4PatchCommandCallback()\n );\n return moduleExports;\n },\n v4PatchConnectionPromise: (moduleExports: any) => {\n // patch insert operation\n if (isWrapped(moduleExports.Connection.prototype.command)) {\n this._unwrap(moduleExports.Connection.prototype, 'command');\n }\n\n this._wrap(\n moduleExports.Connection.prototype,\n 'command',\n this._getV4PatchCommandPromise()\n );\n return moduleExports;\n },\n v4UnpatchConnection: (moduleExports?: any) => {\n if (moduleExports === undefined) return;\n this._unwrap(moduleExports.Connection.prototype, 'command');\n },\n };\n }\n\n /** Creates spans for common operations */\n private _getV3PatchOperation(operationName: 'insert' | 'update' | 'remove') {\n const instrumentation = this;\n return (original: WireProtocolInternal[typeof operationName]) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n ops: unknown[],\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof ops !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, ops, options);\n } else {\n return original.call(this, server, ns, ops, options, callback);\n }\n }\n const span = instrumentation.tracer.startSpan(\n `mongodb.${operationName}`,\n {\n kind: SpanKind.CLIENT,\n }\n );\n\n instrumentation._populateV3Attributes(\n span,\n ns,\n server,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ops[0] as any,\n operationName\n );\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(this, server, ns, ops, patchedCallback);\n } else {\n return original.call(this, server, ns, ops, options, patchedCallback);\n }\n };\n };\n }\n\n /** Creates spans for command operation */\n private _getV3PatchCommand() {\n const instrumentation = this;\n return (original: WireProtocolInternal['command']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cmd: MongoInternalCommand,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, options);\n } else {\n return original.call(this, server, ns, cmd, options, callback);\n }\n }\n const commandType = MongoDBInstrumentation._getCommandType(cmd);\n const type =\n commandType === MongodbCommandType.UNKNOWN ? 'command' : commandType;\n const span = instrumentation.tracer.startSpan(`mongodb.${type}`, {\n kind: SpanKind.CLIENT,\n });\n const operation =\n commandType === MongodbCommandType.UNKNOWN ? undefined : commandType;\n instrumentation._populateV3Attributes(span, ns, server, cmd, operation);\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, patchedCallback);\n } else {\n return original.call(this, server, ns, cmd, options, patchedCallback);\n }\n };\n };\n }\n\n /** Creates spans for command operation */\n private _getV4PatchCommandCallback() {\n const instrumentation = this;\n return (original: V4Connection['commandCallback']) => {\n return function patchedV4ServerCommand(\n this: any,\n ns: any,\n cmd: any,\n options: undefined | unknown,\n callback: any\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler = callback;\n const commandType = Object.keys(cmd)[0];\n\n if (\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object' ||\n cmd.ismaster ||\n cmd.hello\n ) {\n return original.call(this, ns, cmd, options, callback);\n }\n\n let span = undefined;\n if (currentSpan) {\n span = instrumentation.tracer.startSpan(`mongodb.${commandType}`, {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV4Attributes(\n span,\n this,\n ns,\n cmd,\n commandType\n );\n }\n const patchedCallback = instrumentation._patchEnd(\n span,\n resultHandler,\n this.id,\n commandType\n );\n\n return original.call(this, ns, cmd, options, patchedCallback);\n };\n };\n }\n\n private _getV4PatchCommandPromise() {\n const instrumentation = this;\n return (original: V4Connection['commandPromise']) => {\n return function patchedV4ServerCommand(\n this: any,\n ns: any,\n cmd: any,\n options: undefined | unknown\n ) {\n const currentSpan = trace.getSpan(context.active());\n const commandType = Object.keys(cmd)[0];\n const resultHandler = () => undefined;\n\n if (typeof cmd !== 'object' || cmd.ismaster || cmd.hello) {\n return original.call(this, ns, cmd, options);\n }\n\n let span = undefined;\n if (currentSpan) {\n span = instrumentation.tracer.startSpan(`mongodb.${commandType}`, {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV4Attributes(\n span,\n this,\n ns,\n cmd,\n commandType\n );\n }\n\n const patchedCallback = instrumentation._patchEnd(\n span,\n resultHandler,\n this.id,\n commandType\n );\n\n const result = original.call(this, ns, cmd, options);\n result.then(\n (res: any) => patchedCallback(null, res),\n (err: any) => patchedCallback(err)\n );\n\n return result;\n };\n };\n }\n\n /** Creates spans for find operation */\n private _getV3PatchFind() {\n const instrumentation = this;\n return (original: WireProtocolInternal['query']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cmd: MongoInternalCommand,\n cursorState: CursorState,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (\n !currentSpan ||\n typeof resultHandler !== 'function' ||\n typeof cmd !== 'object'\n ) {\n if (typeof options === 'function') {\n return original.call(this, server, ns, cmd, cursorState, options);\n } else {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n options,\n callback\n );\n }\n }\n const span = instrumentation.tracer.startSpan('mongodb.find', {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV3Attributes(span, ns, server, cmd, 'find');\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n patchedCallback\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cmd,\n cursorState,\n options,\n patchedCallback\n );\n }\n };\n };\n }\n\n /** Creates spans for find operation */\n private _getV3PatchCursor() {\n const instrumentation = this;\n return (original: WireProtocolInternal['getMore']) => {\n return function patchedServerCommand(\n this: unknown,\n server: MongoInternalTopology,\n ns: string,\n cursorState: CursorState,\n batchSize: number,\n options: unknown | Function,\n callback?: Function\n ) {\n const currentSpan = trace.getSpan(context.active());\n const resultHandler =\n typeof options === 'function' ? options : callback;\n if (!currentSpan || typeof resultHandler !== 'function') {\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options,\n callback\n );\n }\n }\n const span = instrumentation.tracer.startSpan('mongodb.getMore', {\n kind: SpanKind.CLIENT,\n });\n instrumentation._populateV3Attributes(\n span,\n ns,\n server,\n cursorState.cmd,\n 'getMore'\n );\n const patchedCallback = instrumentation._patchEnd(span, resultHandler);\n // handle when options is the callback to send the correct number of args\n if (typeof options === 'function') {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n patchedCallback\n );\n } else {\n return original.call(\n this,\n server,\n ns,\n cursorState,\n batchSize,\n options,\n patchedCallback\n );\n }\n };\n };\n }\n\n /**\n * Get the mongodb command type from the object.\n * @param command Internal mongodb command object\n */\n private static _getCommandType(\n command: MongoInternalCommand\n ): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n }\n\n /**\n * Populate span's attributes by fetching related metadata from the context\n * @param span span to add attributes to\n * @param connectionCtx mongodb internal connection context\n * @param ns mongodb namespace\n * @param command mongodb internal representation of a command\n */\n private _populateV4Attributes(\n span: Span,\n connectionCtx: any,\n ns: any,\n command?: any,\n operation?: string\n ) {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts =\n typeof connectionCtx.address === 'string'\n ? connectionCtx.address.split(':')\n : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n // capture parameters within the query as well if enhancedDatabaseReporting is enabled.\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n this._addAllSpanAttributes(\n span,\n ns.db,\n ns.collection,\n host,\n port,\n commandObj,\n operation\n );\n }\n\n /**\n * Populate span's attributes by fetching related metadata from the context\n * @param span span to add attributes to\n * @param ns mongodb namespace\n * @param topology mongodb internal representation of the network topology\n * @param command mongodb internal representation of a command\n */\n private _populateV3Attributes(\n span: Span,\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined\n ) {\n // add network attributes to determine the remote server\n let host: undefined | string;\n let port: undefined | string;\n if (topology && topology.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n // capture parameters within the query as well if enhancedDatabaseReporting is enabled.\n const commandObj = command?.query ?? command?.q ?? command;\n\n this._addAllSpanAttributes(\n span,\n dbName,\n dbCollection,\n host,\n port,\n commandObj,\n operation\n );\n }\n\n private _addAllSpanAttributes(\n span: Span,\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined\n ) {\n // add database related attributes\n span.setAttributes({\n [SEMATTRS_DB_SYSTEM]: DBSYSTEMVALUES_MONGODB,\n [SEMATTRS_DB_NAME]: dbName,\n [SEMATTRS_DB_MONGODB_COLLECTION]: dbCollection,\n [SEMATTRS_DB_OPERATION]: operation,\n [SEMATTRS_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n });\n\n if (host && port) {\n span.setAttribute(SEMATTRS_NET_PEER_NAME, host);\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n span.setAttribute(SEMATTRS_NET_PEER_PORT, portNumber);\n }\n }\n if (!commandObj) return;\n const dbStatementSerializer =\n typeof this._config.dbStatementSerializer === 'function'\n ? this._config.dbStatementSerializer\n : this._defaultDbStatementSerializer.bind(this);\n\n safeExecuteInTheMiddle(\n () => {\n const query = dbStatementSerializer(commandObj);\n span.setAttribute(SEMATTRS_DB_STATEMENT, query);\n },\n err => {\n if (err) {\n this._diag.error('Error running dbStatementSerializer hook', err);\n }\n },\n true\n );\n }\n\n private _defaultDbStatementSerializer(commandObj: Record<string, unknown>) {\n const enhancedDbReporting = !!this._config?.enhancedDatabaseReporting;\n const resultObj = enhancedDbReporting\n ? commandObj\n : Object.keys(commandObj).reduce((obj, key) => {\n obj[key] = '?';\n return obj;\n }, {} as { [key: string]: unknown });\n return JSON.stringify(resultObj);\n }\n\n /**\n * Triggers the response hook in case it is defined.\n * @param span The span to add the results to.\n * @param result The command result\n */\n private _handleExecutionResult(span: Span, result: CommandResult) {\n const config: MongoDBInstrumentationConfig = this.getConfig();\n if (typeof config.responseHook === 'function') {\n safeExecuteInTheMiddle(\n () => {\n config.responseHook!(span, { data: result });\n },\n err => {\n if (err) {\n this._diag.error('Error running response hook', err);\n }\n },\n true\n );\n }\n }\n\n /**\n * Ends a created span.\n * @param span The created span to end.\n * @param resultHandler A callback function.\n * @param connectionId: The connection ID of the Command response.\n */\n private _patchEnd(\n span: Span | undefined,\n resultHandler: Function,\n connectionId?: number,\n commandType?: string\n ): Function {\n // mongodb is using \"tick\" when calling a callback, this way the context\n // in final callback (resultHandler) is lost\n const activeContext = context.active();\n const instrumentation = this;\n return function patchedEnd(this: {}, ...args: unknown[]) {\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span?.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n } else {\n const result = args[1] as CommandResult;\n instrumentation._handleExecutionResult(span, result);\n }\n span.end();\n }\n\n return context.with(activeContext, () => {\n if (commandType === 'endSessions') {\n instrumentation._connectionsUsage.add(-1, {\n state: 'idle',\n 'pool.name': instrumentation._poolName,\n });\n }\n return resultHandler.apply(this, args);\n });\n };\n }\n private setPoolName(options: any) {\n const host = options.hostAddress?.host;\n const port = options.hostAddress?.port;\n const database = options.dbName;\n const poolName = `mongodb://${host}:${port}/${database}`;\n this._poolName = poolName;\n }\n}\n"]}
@@ -1,2 +1,3 @@
1
- export declare const VERSION = "0.42.0";
1
+ export declare const PACKAGE_VERSION = "0.44.0";
2
+ export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-mongodb";
2
3
  //# sourceMappingURL=version.d.ts.map
@@ -15,7 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.VERSION = void 0;
18
+ exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.42.0';
20
+ exports.PACKAGE_VERSION = '0.44.0';
21
+ exports.PACKAGE_NAME = '@opentelemetry/instrumentation-mongodb';
21
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,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.42.0';\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.44.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-mongodb';\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-mongodb",
3
- "version": "0.42.0",
4
- "description": "OpenTelemetry mongodb automatic instrumentation package.",
3
+ "version": "0.44.0",
4
+ "description": "OpenTelemetry instrumentation for `mongodb` database client for MongoDB",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
7
7
  "repository": "open-telemetry/opentelemetry-js-contrib",
@@ -50,7 +50,7 @@
50
50
  "devDependencies": {
51
51
  "@opentelemetry/api": "^1.3.0",
52
52
  "@opentelemetry/context-async-hooks": "^1.8.0",
53
- "@opentelemetry/contrib-test-utils": "^0.38.0",
53
+ "@opentelemetry/contrib-test-utils": "^0.40.0",
54
54
  "@opentelemetry/sdk-trace-base": "^1.8.0",
55
55
  "@opentelemetry/sdk-trace-node": "^1.8.0",
56
56
  "@types/bson": "4.0.5",
@@ -66,10 +66,10 @@
66
66
  "typescript": "4.4.4"
67
67
  },
68
68
  "dependencies": {
69
- "@opentelemetry/instrumentation": "^0.50.0",
69
+ "@opentelemetry/instrumentation": "^0.52.0",
70
70
  "@opentelemetry/sdk-metrics": "^1.9.1",
71
- "@opentelemetry/semantic-conventions": "^1.0.0"
71
+ "@opentelemetry/semantic-conventions": "^1.22.0"
72
72
  },
73
73
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-mongodb#readme",
74
- "gitHead": "17a0bc1da3baa472ba9b867eee3c60730cc130fb"
74
+ "gitHead": "0af1b70f7c3c9763c85ac51fa5e334c1e1512020"
75
75
  }