@opentelemetry/instrumentation-mongoose 0.40.0 → 0.42.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/README.md CHANGED
@@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-mongoose
17
17
 
18
18
  ## Supported Versions
19
19
 
20
- - [`mongoose`](https://www.npmjs.com/package/mongoose) versions `>=5.9.7 <7`
20
+ - [`mongoose`](https://www.npmjs.com/package/mongoose) versions `>=5.9.7 <9`
21
21
 
22
22
  ## Usage
23
23
 
@@ -1,10 +1,8 @@
1
1
  import { MongooseInstrumentationConfig } from './types';
2
2
  import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
3
3
  export declare const _STORED_PARENT_SPAN: unique symbol;
4
- export declare class MongooseInstrumentation extends InstrumentationBase {
5
- protected _config: MongooseInstrumentationConfig;
4
+ export declare class MongooseInstrumentation extends InstrumentationBase<MongooseInstrumentationConfig> {
6
5
  constructor(config?: MongooseInstrumentationConfig);
7
- setConfig(config?: MongooseInstrumentationConfig): void;
8
6
  protected init(): InstrumentationModuleDefinition;
9
7
  private patch;
10
8
  private unpatch;
@@ -22,23 +22,52 @@ const utils_1 = require("./utils");
22
22
  const instrumentation_1 = require("@opentelemetry/instrumentation");
23
23
  const version_1 = require("./version");
24
24
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
25
- const contextCaptureFunctions = [
26
- 'remove',
25
+ const contextCaptureFunctionsCommon = [
27
26
  'deleteOne',
28
27
  'deleteMany',
29
28
  'find',
30
29
  'findOne',
31
30
  'estimatedDocumentCount',
32
31
  'countDocuments',
33
- 'count',
34
32
  'distinct',
35
33
  'where',
36
34
  '$where',
37
35
  'findOneAndUpdate',
38
36
  'findOneAndDelete',
39
37
  'findOneAndReplace',
38
+ ];
39
+ const contextCaptureFunctions6 = [
40
+ 'remove',
41
+ 'count',
40
42
  'findOneAndRemove',
43
+ ...contextCaptureFunctionsCommon,
41
44
  ];
45
+ const contextCaptureFunctions7 = [
46
+ 'count',
47
+ 'findOneAndRemove',
48
+ ...contextCaptureFunctionsCommon,
49
+ ];
50
+ const contextCaptureFunctions8 = [...contextCaptureFunctionsCommon];
51
+ function getContextCaptureFunctions(moduleVersion) {
52
+ /* istanbul ignore next */
53
+ if (!moduleVersion) {
54
+ return contextCaptureFunctionsCommon;
55
+ }
56
+ else if (moduleVersion.startsWith('6.') || moduleVersion.startsWith('5.')) {
57
+ return contextCaptureFunctions6;
58
+ }
59
+ else if (moduleVersion.startsWith('7.')) {
60
+ return contextCaptureFunctions7;
61
+ }
62
+ else {
63
+ return contextCaptureFunctions8;
64
+ }
65
+ }
66
+ function instrumentRemove(moduleVersion) {
67
+ return ((moduleVersion &&
68
+ (moduleVersion.startsWith('5.') || moduleVersion.startsWith('6.'))) ||
69
+ false);
70
+ }
42
71
  // when mongoose functions are called, we store the original call context
43
72
  // and then set it as the parent for the spans created by Query/Aggregate exec()
44
73
  // calls. this bypass the unlinked spans issue on thenables await operations.
@@ -47,11 +76,8 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
47
76
  constructor(config = {}) {
48
77
  super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, config);
49
78
  }
50
- setConfig(config = {}) {
51
- this._config = Object.assign({}, config);
52
- }
53
79
  init() {
54
- const module = new instrumentation_1.InstrumentationNodeModuleDefinition('mongoose', ['>=5.9.7 <7'], this.patch.bind(this), this.unpatch.bind(this));
80
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition('mongoose', ['>=5.9.7 <9'], this.patch.bind(this), this.unpatch.bind(this));
55
81
  return module;
56
82
  }
57
83
  patch(moduleExports, moduleVersion) {
@@ -61,20 +87,26 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
61
87
  // which captures the save function before it is patched.
62
88
  // so we need to apply the same logic after instrumenting the save function.
63
89
  moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;
64
- this._wrap(moduleExports.Model.prototype, 'remove', this.patchOnModelMethods('remove', moduleVersion));
90
+ if (instrumentRemove(moduleVersion)) {
91
+ this._wrap(moduleExports.Model.prototype, 'remove', this.patchOnModelMethods('remove', moduleVersion));
92
+ }
65
93
  this._wrap(moduleExports.Query.prototype, 'exec', this.patchQueryExec(moduleVersion));
66
94
  this._wrap(moduleExports.Aggregate.prototype, 'exec', this.patchAggregateExec(moduleVersion));
95
+ const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);
67
96
  contextCaptureFunctions.forEach((funcName) => {
68
97
  this._wrap(moduleExports.Query.prototype, funcName, this.patchAndCaptureSpanContext(funcName));
69
98
  });
70
99
  this._wrap(moduleExports.Model, 'aggregate', this.patchModelAggregate());
71
100
  return moduleExports;
72
101
  }
73
- unpatch(moduleExports) {
102
+ unpatch(moduleExports, moduleVersion) {
103
+ const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);
74
104
  this._unwrap(moduleExports.Model.prototype, 'save');
75
105
  // revert the patch for $save which we applied by aliasing it to patched `save`
76
106
  moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;
77
- this._unwrap(moduleExports.Model.prototype, 'remove');
107
+ if (instrumentRemove(moduleVersion)) {
108
+ this._unwrap(moduleExports.Model.prototype, 'remove');
109
+ }
78
110
  this._unwrap(moduleExports.Query.prototype, 'exec');
79
111
  this._unwrap(moduleExports.Aggregate.prototype, 'exec');
80
112
  contextCaptureFunctions.forEach((funcName) => {
@@ -87,18 +119,18 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
87
119
  return (originalAggregate) => {
88
120
  return function exec(callback) {
89
121
  var _a;
90
- if (self._config.requireParentSpan &&
122
+ if (self.getConfig().requireParentSpan &&
91
123
  api_1.trace.getSpan(api_1.context.active()) === undefined) {
92
124
  return originalAggregate.apply(this, arguments);
93
125
  }
94
126
  const parentSpan = this[exports._STORED_PARENT_SPAN];
95
127
  const attributes = {};
96
- if (self._config.dbStatementSerializer) {
97
- attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] =
98
- self._config.dbStatementSerializer('aggregate', {
99
- options: this.options,
100
- aggregatePipeline: this._pipeline,
101
- });
128
+ const { dbStatementSerializer } = self.getConfig();
129
+ if (dbStatementSerializer) {
130
+ attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] = dbStatementSerializer('aggregate', {
131
+ options: this.options,
132
+ aggregatePipeline: this._pipeline,
133
+ });
102
134
  }
103
135
  const span = self._startSpan(this._model.collection, (_a = this._model) === null || _a === void 0 ? void 0 : _a.modelName, 'aggregate', attributes, parentSpan);
104
136
  return self._handleResponse(span, originalAggregate, this, arguments, callback, moduleVersion);
@@ -109,20 +141,20 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
109
141
  const self = this;
110
142
  return (originalExec) => {
111
143
  return function exec(callback) {
112
- if (self._config.requireParentSpan &&
144
+ if (self.getConfig().requireParentSpan &&
113
145
  api_1.trace.getSpan(api_1.context.active()) === undefined) {
114
146
  return originalExec.apply(this, arguments);
115
147
  }
116
148
  const parentSpan = this[exports._STORED_PARENT_SPAN];
117
149
  const attributes = {};
118
- if (self._config.dbStatementSerializer) {
119
- attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] =
120
- self._config.dbStatementSerializer(this.op, {
121
- condition: this._conditions,
122
- updates: this._update,
123
- options: this.options,
124
- fields: this._fields,
125
- });
150
+ const { dbStatementSerializer } = self.getConfig();
151
+ if (dbStatementSerializer) {
152
+ attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] = dbStatementSerializer(this.op, {
153
+ condition: this._conditions,
154
+ updates: this._update,
155
+ options: this.options,
156
+ fields: this._fields,
157
+ });
126
158
  }
127
159
  const span = self._startSpan(this.mongooseCollection, this.model.modelName, this.op, attributes, parentSpan);
128
160
  return self._handleResponse(span, originalExec, this, arguments, callback, moduleVersion);
@@ -133,7 +165,7 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
133
165
  const self = this;
134
166
  return (originalOnModelFunction) => {
135
167
  return function method(options, callback) {
136
- if (self._config.requireParentSpan &&
168
+ if (self.getConfig().requireParentSpan &&
137
169
  api_1.trace.getSpan(api_1.context.active()) === undefined) {
138
170
  return originalOnModelFunction.apply(this, arguments);
139
171
  }
@@ -142,9 +174,9 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
142
174
  serializePayload.options = options;
143
175
  }
144
176
  const attributes = {};
145
- if (self._config.dbStatementSerializer) {
146
- attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] =
147
- self._config.dbStatementSerializer(op, serializePayload);
177
+ const { dbStatementSerializer } = self.getConfig();
178
+ if (dbStatementSerializer) {
179
+ attributes[semantic_conventions_1.SEMATTRS_DB_STATEMENT] = dbStatementSerializer(op, serializePayload);
148
180
  }
149
181
  const span = self._startSpan(this.constructor.collection, this.constructor.modelName, op, attributes);
150
182
  if (options instanceof Function) {
@@ -189,16 +221,15 @@ class MongooseInstrumentation extends instrumentation_1.InstrumentationBase {
189
221
  _handleResponse(span, exec, originalThis, args, callback, moduleVersion = undefined) {
190
222
  const self = this;
191
223
  if (callback instanceof Function) {
192
- return self._callOriginalFunction(() => (0, utils_1.handleCallbackResponse)(callback, exec, originalThis, span, args, self._config.responseHook, moduleVersion));
224
+ return self._callOriginalFunction(() => (0, utils_1.handleCallbackResponse)(callback, exec, originalThis, span, args, self.getConfig().responseHook, moduleVersion));
193
225
  }
194
226
  else {
195
227
  const response = self._callOriginalFunction(() => exec.apply(originalThis, args));
196
- return (0, utils_1.handlePromiseResponse)(response, span, self._config.responseHook, moduleVersion);
228
+ return (0, utils_1.handlePromiseResponse)(response, span, self.getConfig().responseHook, moduleVersion);
197
229
  }
198
230
  }
199
231
  _callOriginalFunction(originalFunction) {
200
- var _a;
201
- if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.suppressInternalInstrumentation) {
232
+ if (this.getConfig().suppressInternalInstrumentation) {
202
233
  return api_1.context.with((0, core_1.suppressTracing)(api_1.context.active()), originalFunction);
203
234
  }
204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SAAS,EAClC,CAAC,yCAAkB,CAAC,EAAE,UAAU,GACjC;SACF,EACD,UAAU,CAAC,CAAC,CAAC,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CACrE,CAAC;IACJ,CAAC;IAEO,eAAe,CACrB,IAAU,EACV,IAAc,EACd,YAAiB,EACjB,IAAgB,EAChB,QAAmB,EACnB,gBAAoC,SAAS;QAE7C,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,QAAQ,YAAY,QAAQ,EAAE;YAChC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,CACrC,IAAA,8BAAsB,EACpB,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,YAAY,EACzB,aAAa,CACd,CACF,CAAC;SACH;aAAM;YACL,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAC/B,CAAC;YACF,OAAO,IAAA,6BAAqB,EAC1B,QAAQ,EACR,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,YAAY,EACzB,aAAa,CACd,CAAC;SACH;IACH,CAAC;IAEO,qBAAqB,CAAI,gBAAuC;;QACtE,IAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,+BAA+B,EAAE;YACjD,OAAO,aAAO,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;SAC1E;aAAM;YACL,OAAO,gBAAgB,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AA1SD,0DA0SC","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 { context, Span, trace, Attributes, SpanKind } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport type * as mongoose from 'mongoose';\nimport { MongooseInstrumentationConfig, SerializerPayload } from './types';\nimport {\n handleCallbackResponse,\n handlePromiseResponse,\n getAttributesFromCollection,\n} from './utils';\nimport {\n InstrumentationBase,\n InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport {\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n} from '@opentelemetry/semantic-conventions';\n\nconst contextCaptureFunctions = [\n 'remove',\n 'deleteOne',\n 'deleteMany',\n 'find',\n 'findOne',\n 'estimatedDocumentCount',\n 'countDocuments',\n 'count',\n 'distinct',\n 'where',\n '$where',\n 'findOneAndUpdate',\n 'findOneAndDelete',\n 'findOneAndReplace',\n 'findOneAndRemove',\n];\n\n// when mongoose functions are called, we store the original call context\n// and then set it as the parent for the spans created by Query/Aggregate exec()\n// calls. this bypass the unlinked spans issue on thenables await operations.\nexport const _STORED_PARENT_SPAN: unique symbol = Symbol('stored-parent-span');\n\nexport class MongooseInstrumentation extends InstrumentationBase {\n protected override _config!: MongooseInstrumentationConfig;\n\n constructor(config: MongooseInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n override setConfig(config: MongooseInstrumentationConfig = {}) {\n this._config = Object.assign({}, config);\n }\n\n protected init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'mongoose',\n ['>=5.9.7 <7'],\n this.patch.bind(this),\n this.unpatch.bind(this)\n );\n return module;\n }\n\n private patch(\n moduleExports: typeof mongoose,\n moduleVersion: string | undefined\n ) {\n this._wrap(\n moduleExports.Model.prototype,\n 'save',\n this.patchOnModelMethods('save', moduleVersion)\n );\n // mongoose applies this code on module require:\n // Model.prototype.$save = Model.prototype.save;\n // which captures the save function before it is patched.\n // so we need to apply the same logic after instrumenting the save function.\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n this._wrap(\n moduleExports.Model.prototype,\n 'remove',\n this.patchOnModelMethods('remove', moduleVersion)\n );\n this._wrap(\n moduleExports.Query.prototype,\n 'exec',\n this.patchQueryExec(moduleVersion)\n );\n this._wrap(\n moduleExports.Aggregate.prototype,\n 'exec',\n this.patchAggregateExec(moduleVersion)\n );\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._wrap(\n moduleExports.Query.prototype,\n funcName as any,\n this.patchAndCaptureSpanContext(funcName)\n );\n });\n this._wrap(moduleExports.Model, 'aggregate', this.patchModelAggregate());\n\n return moduleExports;\n }\n\n private unpatch(moduleExports: typeof mongoose): void {\n this._unwrap(moduleExports.Model.prototype, 'save');\n // revert the patch for $save which we applied by aliasing it to patched `save`\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n this._unwrap(moduleExports.Model.prototype, 'remove');\n this._unwrap(moduleExports.Query.prototype, 'exec');\n this._unwrap(moduleExports.Aggregate.prototype, 'exec');\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._unwrap(moduleExports.Query.prototype, funcName as any);\n });\n this._unwrap(moduleExports.Model, 'aggregate');\n }\n\n private patchAggregateExec(moduleVersion: string | undefined) {\n const self = this;\n return (originalAggregate: Function) => {\n return function exec(this: any, callback?: Function) {\n if (\n self._config.requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalAggregate.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const attributes: Attributes = {};\n if (self._config.dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] =\n self._config.dbStatementSerializer('aggregate', {\n options: this.options,\n aggregatePipeline: this._pipeline,\n });\n }\n\n const span = self._startSpan(\n this._model.collection,\n this._model?.modelName,\n 'aggregate',\n attributes,\n parentSpan\n );\n\n return self._handleResponse(\n span,\n originalAggregate,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n private patchQueryExec(moduleVersion: string | undefined) {\n const self = this;\n return (originalExec: Function) => {\n return function exec(this: any, callback?: Function) {\n if (\n self._config.requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalExec.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const attributes: Attributes = {};\n if (self._config.dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] =\n self._config.dbStatementSerializer(this.op, {\n condition: this._conditions,\n updates: this._update,\n options: this.options,\n fields: this._fields,\n });\n }\n const span = self._startSpan(\n this.mongooseCollection,\n this.model.modelName,\n this.op,\n attributes,\n parentSpan\n );\n\n return self._handleResponse(\n span,\n originalExec,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n private patchOnModelMethods(op: string, moduleVersion: string | undefined) {\n const self = this;\n return (originalOnModelFunction: Function) => {\n return function method(this: any, options?: any, callback?: Function) {\n if (\n self._config.requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalOnModelFunction.apply(this, arguments);\n }\n\n const serializePayload: SerializerPayload = { document: this };\n if (options && !(options instanceof Function)) {\n serializePayload.options = options;\n }\n const attributes: Attributes = {};\n if (self._config.dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] =\n self._config.dbStatementSerializer(op, serializePayload);\n }\n const span = self._startSpan(\n this.constructor.collection,\n this.constructor.modelName,\n op,\n attributes\n );\n\n if (options instanceof Function) {\n callback = options;\n options = undefined;\n }\n\n return self._handleResponse(\n span,\n originalOnModelFunction,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n // we want to capture the otel span on the object which is calling exec.\n // in the special case of aggregate, we need have no function to path\n // on the Aggregate object to capture the context on, so we patch\n // the aggregate of Model, and set the context on the Aggregate object\n private patchModelAggregate() {\n const self = this;\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n const currentSpan = trace.getSpan(context.active());\n const aggregate = self._callOriginalFunction(() =>\n original.apply(this, arguments)\n );\n if (aggregate) aggregate[_STORED_PARENT_SPAN] = currentSpan;\n return aggregate;\n };\n };\n }\n\n private patchAndCaptureSpanContext(funcName: string) {\n const self = this;\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n this[_STORED_PARENT_SPAN] = trace.getSpan(context.active());\n return self._callOriginalFunction(() =>\n original.apply(this, arguments)\n );\n };\n };\n }\n\n private _startSpan(\n collection: mongoose.Collection,\n modelName: string,\n operation: string,\n attributes: Attributes,\n parentSpan?: Span\n ): Span {\n return this.tracer.startSpan(\n `mongoose.${modelName}.${operation}`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n ...attributes,\n ...getAttributesFromCollection(collection),\n [SEMATTRS_DB_OPERATION]: operation,\n [SEMATTRS_DB_SYSTEM]: 'mongoose',\n },\n },\n parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined\n );\n }\n\n private _handleResponse(\n span: Span,\n exec: Function,\n originalThis: any,\n args: IArguments,\n callback?: Function,\n moduleVersion: string | undefined = undefined\n ) {\n const self = this;\n if (callback instanceof Function) {\n return self._callOriginalFunction(() =>\n handleCallbackResponse(\n callback,\n exec,\n originalThis,\n span,\n args,\n self._config.responseHook,\n moduleVersion\n )\n );\n } else {\n const response = self._callOriginalFunction(() =>\n exec.apply(originalThis, args)\n );\n return handlePromiseResponse(\n response,\n span,\n self._config.responseHook,\n moduleVersion\n );\n }\n }\n\n private _callOriginalFunction<T>(originalFunction: (...args: any[]) => T): T {\n if (this._config?.suppressInternalInstrumentation) {\n return context.with(suppressTracing(context.active()), originalFunction);\n } else {\n return originalFunction();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"mongoose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ClB,IAAI,QAAQ,YAAY,QAAQ,EAAE;YAChC,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,CACrC,IAAA,8BAAsB,EACpB,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,EAC7B,aAAa,CACd,CACF,CAAC;SACH;aAAM;YACL,MAAM,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,CAC/C,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAC/B,CAAC;YACF,OAAO,IAAA,6BAAqB,EAC1B,QAAQ,EACR,IAAI,EACJ,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,EAC7B,aAAa,CACd,CAAC;SACH;IACH,CAAC;IAEO,qBAAqB,CAAI,gBAAuC;QACtE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,+BAA+B,EAAE;YACpD,OAAO,aAAO,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;SAC1E;aAAM;YACL,OAAO,gBAAgB,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AAxTD,0DAwTC","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 { context, Span, trace, Attributes, SpanKind } from '@opentelemetry/api';\nimport { suppressTracing } from '@opentelemetry/core';\nimport type * as mongoose from 'mongoose';\nimport { MongooseInstrumentationConfig, SerializerPayload } from './types';\nimport {\n handleCallbackResponse,\n handlePromiseResponse,\n getAttributesFromCollection,\n} from './utils';\nimport {\n InstrumentationBase,\n InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n} from '@opentelemetry/instrumentation';\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport {\n SEMATTRS_DB_OPERATION,\n SEMATTRS_DB_STATEMENT,\n SEMATTRS_DB_SYSTEM,\n} from '@opentelemetry/semantic-conventions';\n\nconst contextCaptureFunctionsCommon = [\n 'deleteOne',\n 'deleteMany',\n 'find',\n 'findOne',\n 'estimatedDocumentCount',\n 'countDocuments',\n 'distinct',\n 'where',\n '$where',\n 'findOneAndUpdate',\n 'findOneAndDelete',\n 'findOneAndReplace',\n];\n\nconst contextCaptureFunctions6 = [\n 'remove',\n 'count',\n 'findOneAndRemove',\n ...contextCaptureFunctionsCommon,\n];\nconst contextCaptureFunctions7 = [\n 'count',\n 'findOneAndRemove',\n ...contextCaptureFunctionsCommon,\n];\nconst contextCaptureFunctions8 = [...contextCaptureFunctionsCommon];\n\nfunction getContextCaptureFunctions(\n moduleVersion: string | undefined\n): string[] {\n /* istanbul ignore next */\n if (!moduleVersion) {\n return contextCaptureFunctionsCommon;\n } else if (moduleVersion.startsWith('6.') || moduleVersion.startsWith('5.')) {\n return contextCaptureFunctions6;\n } else if (moduleVersion.startsWith('7.')) {\n return contextCaptureFunctions7;\n } else {\n return contextCaptureFunctions8;\n }\n}\n\nfunction instrumentRemove(moduleVersion: string | undefined): boolean {\n return (\n (moduleVersion &&\n (moduleVersion.startsWith('5.') || moduleVersion.startsWith('6.'))) ||\n false\n );\n}\n\n// when mongoose functions are called, we store the original call context\n// and then set it as the parent for the spans created by Query/Aggregate exec()\n// calls. this bypass the unlinked spans issue on thenables await operations.\nexport const _STORED_PARENT_SPAN: unique symbol = Symbol('stored-parent-span');\n\nexport class MongooseInstrumentation extends InstrumentationBase<MongooseInstrumentationConfig> {\n constructor(config: MongooseInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n protected init(): InstrumentationModuleDefinition {\n const module = new InstrumentationNodeModuleDefinition(\n 'mongoose',\n ['>=5.9.7 <9'],\n this.patch.bind(this),\n this.unpatch.bind(this)\n );\n return module;\n }\n\n private patch(\n moduleExports: typeof mongoose,\n moduleVersion: string | undefined\n ) {\n this._wrap(\n moduleExports.Model.prototype,\n 'save',\n this.patchOnModelMethods('save', moduleVersion)\n );\n // mongoose applies this code on module require:\n // Model.prototype.$save = Model.prototype.save;\n // which captures the save function before it is patched.\n // so we need to apply the same logic after instrumenting the save function.\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._wrap(\n moduleExports.Model.prototype,\n 'remove',\n this.patchOnModelMethods('remove', moduleVersion)\n );\n }\n\n this._wrap(\n moduleExports.Query.prototype,\n 'exec',\n this.patchQueryExec(moduleVersion)\n );\n this._wrap(\n moduleExports.Aggregate.prototype,\n 'exec',\n this.patchAggregateExec(moduleVersion)\n );\n\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._wrap(\n moduleExports.Query.prototype,\n funcName as any,\n this.patchAndCaptureSpanContext(funcName)\n );\n });\n this._wrap(moduleExports.Model, 'aggregate', this.patchModelAggregate());\n\n return moduleExports;\n }\n\n private unpatch(\n moduleExports: typeof mongoose,\n moduleVersion: string | undefined\n ): void {\n const contextCaptureFunctions = getContextCaptureFunctions(moduleVersion);\n\n this._unwrap(moduleExports.Model.prototype, 'save');\n // revert the patch for $save which we applied by aliasing it to patched `save`\n moduleExports.Model.prototype.$save = moduleExports.Model.prototype.save;\n\n if (instrumentRemove(moduleVersion)) {\n this._unwrap(moduleExports.Model.prototype, 'remove');\n }\n\n this._unwrap(moduleExports.Query.prototype, 'exec');\n this._unwrap(moduleExports.Aggregate.prototype, 'exec');\n\n contextCaptureFunctions.forEach((funcName: string) => {\n this._unwrap(moduleExports.Query.prototype, funcName as any);\n });\n this._unwrap(moduleExports.Model, 'aggregate');\n }\n\n private patchAggregateExec(moduleVersion: string | undefined) {\n const self = this;\n return (originalAggregate: Function) => {\n return function exec(this: any, callback?: Function) {\n if (\n self.getConfig().requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalAggregate.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const attributes: Attributes = {};\n const { dbStatementSerializer } = self.getConfig();\n if (dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] = dbStatementSerializer(\n 'aggregate',\n {\n options: this.options,\n aggregatePipeline: this._pipeline,\n }\n );\n }\n\n const span = self._startSpan(\n this._model.collection,\n this._model?.modelName,\n 'aggregate',\n attributes,\n parentSpan\n );\n\n return self._handleResponse(\n span,\n originalAggregate,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n private patchQueryExec(moduleVersion: string | undefined) {\n const self = this;\n return (originalExec: Function) => {\n return function exec(this: any, callback?: Function) {\n if (\n self.getConfig().requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalExec.apply(this, arguments);\n }\n\n const parentSpan = this[_STORED_PARENT_SPAN];\n const attributes: Attributes = {};\n const { dbStatementSerializer } = self.getConfig();\n if (dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] = dbStatementSerializer(this.op, {\n condition: this._conditions,\n updates: this._update,\n options: this.options,\n fields: this._fields,\n });\n }\n const span = self._startSpan(\n this.mongooseCollection,\n this.model.modelName,\n this.op,\n attributes,\n parentSpan\n );\n\n return self._handleResponse(\n span,\n originalExec,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n private patchOnModelMethods(op: string, moduleVersion: string | undefined) {\n const self = this;\n return (originalOnModelFunction: Function) => {\n return function method(this: any, options?: any, callback?: Function) {\n if (\n self.getConfig().requireParentSpan &&\n trace.getSpan(context.active()) === undefined\n ) {\n return originalOnModelFunction.apply(this, arguments);\n }\n\n const serializePayload: SerializerPayload = { document: this };\n if (options && !(options instanceof Function)) {\n serializePayload.options = options;\n }\n const attributes: Attributes = {};\n const { dbStatementSerializer } = self.getConfig();\n if (dbStatementSerializer) {\n attributes[SEMATTRS_DB_STATEMENT] = dbStatementSerializer(\n op,\n serializePayload\n );\n }\n const span = self._startSpan(\n this.constructor.collection,\n this.constructor.modelName,\n op,\n attributes\n );\n\n if (options instanceof Function) {\n callback = options;\n options = undefined;\n }\n\n return self._handleResponse(\n span,\n originalOnModelFunction,\n this,\n arguments,\n callback,\n moduleVersion\n );\n };\n };\n }\n\n // we want to capture the otel span on the object which is calling exec.\n // in the special case of aggregate, we need have no function to path\n // on the Aggregate object to capture the context on, so we patch\n // the aggregate of Model, and set the context on the Aggregate object\n private patchModelAggregate() {\n const self = this;\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n const currentSpan = trace.getSpan(context.active());\n const aggregate = self._callOriginalFunction(() =>\n original.apply(this, arguments)\n );\n if (aggregate) aggregate[_STORED_PARENT_SPAN] = currentSpan;\n return aggregate;\n };\n };\n }\n\n private patchAndCaptureSpanContext(funcName: string) {\n const self = this;\n return (original: Function) => {\n return function captureSpanContext(this: any) {\n this[_STORED_PARENT_SPAN] = trace.getSpan(context.active());\n return self._callOriginalFunction(() =>\n original.apply(this, arguments)\n );\n };\n };\n }\n\n private _startSpan(\n collection: mongoose.Collection,\n modelName: string,\n operation: string,\n attributes: Attributes,\n parentSpan?: Span\n ): Span {\n return this.tracer.startSpan(\n `mongoose.${modelName}.${operation}`,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n ...attributes,\n ...getAttributesFromCollection(collection),\n [SEMATTRS_DB_OPERATION]: operation,\n [SEMATTRS_DB_SYSTEM]: 'mongoose',\n },\n },\n parentSpan ? trace.setSpan(context.active(), parentSpan) : undefined\n );\n }\n\n private _handleResponse(\n span: Span,\n exec: Function,\n originalThis: any,\n args: IArguments,\n callback?: Function,\n moduleVersion: string | undefined = undefined\n ) {\n const self = this;\n if (callback instanceof Function) {\n return self._callOriginalFunction(() =>\n handleCallbackResponse(\n callback,\n exec,\n originalThis,\n span,\n args,\n self.getConfig().responseHook,\n moduleVersion\n )\n );\n } else {\n const response = self._callOriginalFunction(() =>\n exec.apply(originalThis, args)\n );\n return handlePromiseResponse(\n response,\n span,\n self.getConfig().responseHook,\n moduleVersion\n );\n }\n }\n\n private _callOriginalFunction<T>(originalFunction: (...args: any[]) => T): T {\n if (this.getConfig().suppressInternalInstrumentation) {\n return context.with(suppressTracing(context.active()), originalFunction);\n } else {\n return originalFunction();\n }\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.40.0";
1
+ export declare const PACKAGE_VERSION = "0.42.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-mongoose";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -17,6 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.40.0';
20
+ exports.PACKAGE_VERSION = '0.42.0';
21
21
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-mongoose';
22
22
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,yCAAyC,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.40.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-mongoose';\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,yCAAyC,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.42.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-mongoose';\n"]}
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-mongoose",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "description": "OpenTelemetry instrumentation for `mongoose` database object data modeling (ODM) library 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",
8
8
  "scripts": {
9
9
  "docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo",
10
- "test": "ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
10
+ "test": "npm run test-v5-v6",
11
+ "test-v5-v6": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongoose-common.test.ts' 'test/**/mongoose-v5-v6.test.ts'",
12
+ "test-v7-v8": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/mongoose-common.test.ts' 'test/**/mongoose-v7-v8.test.ts'",
11
13
  "test-all-versions": "tav",
12
14
  "tdd": "npm run test -- --watch-extensions ts --watch",
13
15
  "clean": "rimraf build/*",
@@ -47,24 +49,24 @@
47
49
  },
48
50
  "devDependencies": {
49
51
  "@opentelemetry/api": "^1.3.0",
50
- "@opentelemetry/contrib-test-utils": "^0.40.0",
52
+ "@opentelemetry/contrib-test-utils": "^0.41.0",
51
53
  "@opentelemetry/sdk-trace-base": "^1.8.0",
52
54
  "@types/mocha": "8.2.3",
53
55
  "@types/node": "18.6.5",
54
56
  "expect": "29.2.0",
55
57
  "mocha": "7.2.0",
56
- "mongoose": "6.12.3",
58
+ "mongoose": "6.13.0",
57
59
  "nyc": "15.1.0",
58
- "rimraf": "5.0.5",
60
+ "rimraf": "5.0.10",
59
61
  "test-all-versions": "6.1.0",
60
62
  "ts-mocha": "10.0.0",
61
63
  "typescript": "4.4.4"
62
64
  },
63
65
  "dependencies": {
64
66
  "@opentelemetry/core": "^1.8.0",
65
- "@opentelemetry/instrumentation": "^0.52.0",
66
- "@opentelemetry/semantic-conventions": "^1.22.0"
67
+ "@opentelemetry/instrumentation": "^0.53.0",
68
+ "@opentelemetry/semantic-conventions": "^1.27.0"
67
69
  },
68
70
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-mongoose#readme",
69
- "gitHead": "ad8436d6a4174f2288cb939080cd4e74da94b0d7"
71
+ "gitHead": "9dc58afed8134f95908331bcff35c5d9ec46fe9a"
70
72
  }