@opentelemetry/instrumentation-socket.io 0.37.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
2
2
  import { SocketIoInstrumentationConfig } from './types';
3
- export declare class SocketIoInstrumentation extends InstrumentationBase<any> {
3
+ export declare class SocketIoInstrumentation extends InstrumentationBase {
4
4
  protected _config: SocketIoInstrumentationConfig;
5
5
  constructor(config?: SocketIoInstrumentationConfig);
6
- protected init(): InstrumentationNodeModuleDefinition<any>[];
6
+ protected init(): InstrumentationNodeModuleDefinition[];
7
7
  setConfig(config?: SocketIoInstrumentationConfig): void;
8
8
  private _patchOn;
9
9
  private endSpan;
@@ -43,7 +43,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
43
43
  if (moduleVersion === undefined) {
44
44
  return moduleExports;
45
45
  }
46
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`);
47
46
  if ((0, instrumentation_1.isWrapped)((_b = (_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Socket) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.on)) {
48
47
  this._unwrap(moduleExports.Socket.prototype, 'on');
49
48
  }
@@ -71,7 +70,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
71
70
  if (moduleVersion === undefined) {
72
71
  return moduleExports;
73
72
  }
74
- this._diag.debug(`applying patch to socket.io@${moduleVersion} StrictEventEmitter`);
75
73
  if ((0, instrumentation_1.isWrapped)((_b = (_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.BroadcastOperator) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.emit)) {
76
74
  this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');
77
75
  }
@@ -92,7 +90,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
92
90
  if (moduleVersion === undefined) {
93
91
  return moduleExports;
94
92
  }
95
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Namespace`);
96
93
  if ((0, instrumentation_1.isWrapped)((_b = (_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Namespace) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.emit)) {
97
94
  this._unwrap(moduleExports.Namespace.prototype, 'emit');
98
95
  }
@@ -112,7 +109,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
112
109
  if (moduleVersion === undefined) {
113
110
  return moduleExports;
114
111
  }
115
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`);
116
112
  if ((0, instrumentation_1.isWrapped)((_a = moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
117
113
  this._unwrap(moduleExports.prototype, 'on');
118
114
  }
@@ -140,7 +136,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
140
136
  if (moduleVersion === undefined) {
141
137
  return moduleExports;
142
138
  }
143
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Namespace`);
144
139
  if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.emit)) {
145
140
  this._unwrap(moduleExports.prototype, 'emit');
146
141
  }
@@ -161,13 +156,12 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
161
156
  if (moduleVersion === undefined) {
162
157
  return moduleExports;
163
158
  }
164
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Server`);
165
159
  if ((0, instrumentation_1.isWrapped)((_b = (_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Server) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.on)) {
166
160
  this._unwrap(moduleExports.Server.prototype, 'on');
167
161
  }
168
162
  this._wrap(moduleExports.Server.prototype, 'on', this._patchOn(moduleVersion));
169
163
  return moduleExports;
170
- }, (moduleExports, moduleVersion) => {
164
+ }, moduleExports => {
171
165
  var _a, _b;
172
166
  if ((0, instrumentation_1.isWrapped)((_b = (_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Server) === null || _a === void 0 ? void 0 : _a.prototype) === null || _b === void 0 ? void 0 : _b.on)) {
173
167
  this._unwrap(moduleExports.Server.prototype, 'on');
@@ -186,7 +180,6 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
186
180
  if (moduleVersion === undefined) {
187
181
  return moduleExports;
188
182
  }
189
- this._diag.debug(`applying patch to socket.io@${moduleVersion} Server`);
190
183
  if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
191
184
  this._unwrap(moduleExports.prototype, 'on');
192
185
  }
@@ -1 +1 @@
1
- {"version":3,"file":"socket.io.js","sourceRoot":"","sources":["../../src/socket.io.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAC5B,oEAMwC;AACxC,8EAI6C;AAE7C,qDAAqE;AACrE,uCAAoC;AACpC,mCAIiB;AAEjB,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,eAAe;IACf,YAAY;IACZ,eAAe;IACf,aAAa;IACb,gBAAgB;CACjB,CAAC;AAEF,MAAa,uBAAwB,SAAQ,qCAAwB;IAGnE,YAAY,SAAwC,EAAE;QACpD,KAAK,CACH,0CAA0C,EAC1C,iBAAO,EACP,IAAA,uBAAe,EAAC,MAAM,CAAC,CACxB,CAAC;IACJ,CAAC;IAES,IAAI;QACZ,MAAM,qBAAqB,GAAG,IAAI,+CAA6B,CAC7D,0BAA0B,EAC1B,CAAC,QAAQ,CAAC,EACV,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE;;YAC/B,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAA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C,EAAE,CAAC;gBAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,GAAG,SAAS,OAAO,EAAE;oBAClE,IAAI,EAAE,cAAQ,CAAC,QAAQ;oBACvB,UAAU;iBACX,CAAC,CAAC;gBAEH,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;oBACzB,IAAA,wCAAsB,EACpB,GAAG,EAAE,eACH,OAAA,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,QAAQ,mDAAG,IAAI,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA,EAAA,EACjE,CAAC,CAAC,EAAE;wBACF,IAAI,CAAC;4BAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;oBAC/C,CAAC,EACD,IAAI,CACL,CAAC;iBACH;gBACD,IAAI;oBACF,OAAO,aAAO,CAAC,IAAI,CAAC,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,CAC9D,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAChC,CAAC;iBACH;gBAAC,OAAO,KAAU,EAAE;oBACnB,IAAI,CAAC,SAAS,CAAC;wBACb,IAAI,EAAE,oBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;qBACvB,CAAC,CAAC;oBACH,MAAM,KAAK,CAAC;iBACb;wBAAS;oBACR,IAAI,CAAC,GAAG,EAAE,CAAC;iBACZ;YACH,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF;AA7YD,0DA6YC","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 InstrumentationNodeModuleFile,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n SemanticAttributes,\n MessagingOperationValues,\n MessagingDestinationKindValues,\n} from '@opentelemetry/semantic-conventions';\nimport { SocketIoInstrumentationConfig } from './types';\nimport { SocketIoInstrumentationAttributes } from './AttributeNames';\nimport { VERSION } from './version';\nimport {\n extractRoomsAttributeValue,\n isPromise,\n normalizeConfig,\n} from './utils';\n\nconst reservedEvents = [\n 'connect',\n 'connect_error',\n 'disconnect',\n 'disconnecting',\n 'newListener',\n 'removeListener',\n];\n\nexport class SocketIoInstrumentation extends InstrumentationBase<any> {\n protected override _config!: SocketIoInstrumentationConfig;\n\n constructor(config: SocketIoInstrumentationConfig = {}) {\n super(\n '@opentelemetry/instrumentation-socket.io',\n VERSION,\n normalizeConfig(config)\n );\n }\n\n protected init() {\n const socketInstrumentation = new InstrumentationNodeModuleFile<any>(\n 'socket.io/dist/socket.js',\n ['>=3 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`);\n if (isWrapped(moduleExports?.Socket?.prototype?.on)) {\n this._unwrap(moduleExports.Socket.prototype, 'on');\n }\n this._wrap(\n moduleExports.Socket.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n if (isWrapped(moduleExports?.Socket?.prototype?.emit)) {\n this._unwrap(moduleExports.Socket.prototype, 'emit');\n }\n this._wrap(\n moduleExports.Socket.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.Socket?.prototype?.on)) {\n this._unwrap(moduleExports.Socket.prototype, 'on');\n }\n if (isWrapped(moduleExports?.Socket?.prototype?.emit)) {\n this._unwrap(moduleExports.Socket.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n\n const broadcastOperatorInstrumentation =\n new InstrumentationNodeModuleFile<any>(\n 'socket.io/dist/broadcast-operator.js',\n ['>=4 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(\n `applying patch to socket.io@${moduleVersion} StrictEventEmitter`\n );\n if (isWrapped(moduleExports?.BroadcastOperator?.prototype?.emit)) {\n this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');\n }\n this._wrap(\n moduleExports.BroadcastOperator.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.BroadcastOperator?.prototype?.emit)) {\n this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n const namespaceInstrumentation = new InstrumentationNodeModuleFile<any>(\n 'socket.io/dist/namespace.js',\n ['<4'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(\n `applying patch to socket.io@${moduleVersion} Namespace`\n );\n if (isWrapped(moduleExports?.Namespace?.prototype?.emit)) {\n this._unwrap(moduleExports.Namespace.prototype, 'emit');\n }\n this._wrap(\n moduleExports.Namespace.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.Namespace?.prototype?.emit)) {\n this._unwrap(moduleExports.Namespace.prototype, 'emit');\n }\n }\n );\n const socketInstrumentationLegacy = new InstrumentationNodeModuleFile<any>(\n 'socket.io/lib/socket.js',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(`applying patch to socket.io@${moduleVersion} Socket`);\n if (isWrapped(moduleExports.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n this._wrap(moduleExports.prototype, 'on', this._patchOn(moduleVersion));\n if (isWrapped(moduleExports.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n this._wrap(\n moduleExports.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n if (isWrapped(moduleExports.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n const namespaceInstrumentationLegacy =\n new InstrumentationNodeModuleFile<any>(\n 'socket.io/lib/namespace.js',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(\n `applying patch to socket.io@${moduleVersion} Namespace`\n );\n if (isWrapped(moduleExports?.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n this._wrap(\n moduleExports.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n }\n );\n\n return [\n new InstrumentationNodeModuleDefinition<any>(\n 'socket.io',\n ['>=3 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(\n `applying patch to socket.io@${moduleVersion} Server`\n );\n if (isWrapped(moduleExports?.Server?.prototype?.on)) {\n this._unwrap(moduleExports.Server.prototype, 'on');\n }\n this._wrap(\n moduleExports.Server.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n return moduleExports;\n },\n (moduleExports, moduleVersion) => {\n if (isWrapped(moduleExports?.Server?.prototype?.on)) {\n this._unwrap(moduleExports.Server.prototype, 'on');\n }\n return moduleExports;\n },\n [\n broadcastOperatorInstrumentation,\n namespaceInstrumentation,\n socketInstrumentation,\n ]\n ),\n new InstrumentationNodeModuleDefinition<any>(\n 'socket.io',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n this._diag.debug(\n `applying patch to socket.io@${moduleVersion} Server`\n );\n if (isWrapped(moduleExports?.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n this._wrap(\n moduleExports.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n return moduleExports;\n },\n (moduleExports, moduleVersion) => {\n if (isWrapped(moduleExports?.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n return moduleExports;\n },\n [namespaceInstrumentationLegacy, socketInstrumentationLegacy]\n ),\n ];\n }\n\n override setConfig(config: SocketIoInstrumentationConfig = {}) {\n return super.setConfig(normalizeConfig(config));\n }\n\n private _patchOn(moduleVersion: string) {\n const self = this;\n return (original: Function) => {\n return function (this: any, ev: any, originalListener: Function) {\n if (!self._config.traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self._config.onIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const wrappedListener = function (this: any, ...args: any[]) {\n const eventName = ev;\n const defaultNamespace = '/';\n const namespace = this.name || this.adapter?.nsp?.name;\n const destination =\n namespace === defaultNamespace\n ? eventName\n : `${namespace} ${eventName}`;\n const span: Span = self.tracer.startSpan(\n `${destination} ${MessagingOperationValues.RECEIVE}`,\n {\n kind: SpanKind.CONSUMER,\n attributes: {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'socket.io',\n [SemanticAttributes.MESSAGING_DESTINATION]: namespace,\n [SemanticAttributes.MESSAGING_OPERATION]:\n MessagingOperationValues.RECEIVE,\n [SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]:\n eventName,\n },\n }\n );\n\n if (self._config.onHook) {\n safeExecuteInTheMiddle(\n () =>\n self._config?.onHook?.(span, { moduleVersion, payload: args }),\n e => {\n if (e) self._diag.error('onHook error', e);\n },\n true\n );\n }\n return context.with(trace.setSpan(context.active(), span), () =>\n self.endSpan(() => originalListener.apply(this, arguments), span)\n );\n };\n return original.apply(this, [ev, wrappedListener]);\n };\n };\n }\n\n private endSpan(traced: () => any | Promise<any>, span: Span) {\n try {\n const result = traced();\n if (isPromise(result)) {\n return result.then(\n value => {\n span.end();\n return value;\n },\n err => {\n span.recordException(err);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err?.message,\n });\n span.end();\n throw err;\n }\n );\n } else {\n span.end();\n return result;\n }\n } catch (error: any) {\n span.recordException(error);\n span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });\n span.end();\n throw error;\n }\n }\n\n private _patchEmit(moduleVersion: string) {\n const self = this;\n return (original: Function) => {\n return function (this: any, ev: any, ...args: any[]) {\n if (!self._config.traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self._config?.emitIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const messagingSystem = 'socket.io';\n const eventName = ev;\n const attributes: any = {\n [SemanticAttributes.MESSAGING_SYSTEM]: messagingSystem,\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.TOPIC,\n [SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]: eventName,\n };\n\n const rooms = extractRoomsAttributeValue(this);\n if (rooms.length) {\n attributes[SocketIoInstrumentationAttributes.SOCKET_IO_ROOMS] = rooms;\n }\n const namespace =\n this.name || this.adapter?.nsp?.name || this.sockets?.name;\n if (namespace) {\n attributes[SocketIoInstrumentationAttributes.SOCKET_IO_NAMESPACE] =\n namespace;\n attributes[SemanticAttributes.MESSAGING_DESTINATION] = namespace;\n }\n const spanRooms = rooms.length ? `[${rooms.join()}]` : '';\n const span = self.tracer.startSpan(`${namespace}${spanRooms} send`, {\n kind: SpanKind.PRODUCER,\n attributes,\n });\n\n if (self._config.emitHook) {\n safeExecuteInTheMiddle(\n () =>\n self._config.emitHook?.(span, { moduleVersion, payload: args }),\n e => {\n if (e) self._diag.error('emitHook error', e);\n },\n true\n );\n }\n try {\n return context.with(trace.setSpan(context.active(), span), () =>\n original.apply(this, arguments)\n );\n } catch (error: any) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n throw error;\n } finally {\n span.end();\n }\n };\n };\n }\n}\n"]}
1
+ {"version":3,"file":"socket.io.js","sourceRoot":"","sources":["../../src/socket.io.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAC5B,oEAMwC;AACxC,8EAI6C;AAE7C,qDAAqE;AACrE,uCAAoC;AACpC,mCAIiB;AAEjB,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,eAAe;IACf,YAAY;IACZ,eAAe;IACf,aAAa;IACb,gBAAgB;CACjB,CAAC;AAEF,MAAa,uBAAwB,SAAQ,qCAAmB;IAG9D,YAAY,SAAwC,EAAE;QACpD,KAAK,CACH,0CAA0C,EAC1C,iBAAO,EACP,IAAA,uBAAe,EAAC,MAAM,CAAC,CACxB,CAAC;IACJ,CAAC;IAES,IAAI;QACZ,MAAM,qBAAqB,GAAG,IAAI,+CAA6B,CAC7D,0BAA0B,EAC1B,CAAC,QAAQ,CAAC,EACV,CAAC,aAAa,EAAE,aAAa,EAAE,EAAE;;YAC/B,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,IAAI,EAAE;gBACzD,OAAO,aAAa,CAAC;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IAAI;oBACF,OAAO,aAAO,CAAC,IAAI,CAAC,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,CAC9D,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAChC,CAAC;iBACH;gBAAC,OAAO,KAAU,EAAE;oBACnB,IAAI,CAAC,SAAS,CAAC;wBACb,IAAI,EAAE,oBAAc,CAAC,KAAK;wBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;qBACvB,CAAC,CAAC;oBACH,MAAM,KAAK,CAAC;iBACb;wBAAS;oBACR,IAAI,CAAC,GAAG,EAAE,CAAC;iBACZ;YACH,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF;AA1XD,0DA0XC","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 InstrumentationNodeModuleFile,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n SemanticAttributes,\n MessagingOperationValues,\n MessagingDestinationKindValues,\n} from '@opentelemetry/semantic-conventions';\nimport { SocketIoInstrumentationConfig } from './types';\nimport { SocketIoInstrumentationAttributes } from './AttributeNames';\nimport { VERSION } from './version';\nimport {\n extractRoomsAttributeValue,\n isPromise,\n normalizeConfig,\n} from './utils';\n\nconst reservedEvents = [\n 'connect',\n 'connect_error',\n 'disconnect',\n 'disconnecting',\n 'newListener',\n 'removeListener',\n];\n\nexport class SocketIoInstrumentation extends InstrumentationBase {\n protected override _config!: SocketIoInstrumentationConfig;\n\n constructor(config: SocketIoInstrumentationConfig = {}) {\n super(\n '@opentelemetry/instrumentation-socket.io',\n VERSION,\n normalizeConfig(config)\n );\n }\n\n protected init() {\n const socketInstrumentation = new InstrumentationNodeModuleFile(\n 'socket.io/dist/socket.js',\n ['>=3 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.Socket?.prototype?.on)) {\n this._unwrap(moduleExports.Socket.prototype, 'on');\n }\n this._wrap(\n moduleExports.Socket.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n if (isWrapped(moduleExports?.Socket?.prototype?.emit)) {\n this._unwrap(moduleExports.Socket.prototype, 'emit');\n }\n this._wrap(\n moduleExports.Socket.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.Socket?.prototype?.on)) {\n this._unwrap(moduleExports.Socket.prototype, 'on');\n }\n if (isWrapped(moduleExports?.Socket?.prototype?.emit)) {\n this._unwrap(moduleExports.Socket.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n\n const broadcastOperatorInstrumentation = new InstrumentationNodeModuleFile(\n 'socket.io/dist/broadcast-operator.js',\n ['>=4 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.BroadcastOperator?.prototype?.emit)) {\n this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');\n }\n this._wrap(\n moduleExports.BroadcastOperator.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.BroadcastOperator?.prototype?.emit)) {\n this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n const namespaceInstrumentation = new InstrumentationNodeModuleFile(\n 'socket.io/dist/namespace.js',\n ['<4'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.Namespace?.prototype?.emit)) {\n this._unwrap(moduleExports.Namespace.prototype, 'emit');\n }\n this._wrap(\n moduleExports.Namespace.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.Namespace?.prototype?.emit)) {\n this._unwrap(moduleExports.Namespace.prototype, 'emit');\n }\n }\n );\n const socketInstrumentationLegacy = new InstrumentationNodeModuleFile(\n 'socket.io/lib/socket.js',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n this._wrap(moduleExports.prototype, 'on', this._patchOn(moduleVersion));\n if (isWrapped(moduleExports.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n this._wrap(\n moduleExports.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n if (isWrapped(moduleExports.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n return moduleExports;\n }\n );\n const namespaceInstrumentationLegacy = new InstrumentationNodeModuleFile(\n 'socket.io/lib/namespace.js',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n this._wrap(\n moduleExports.prototype,\n 'emit',\n this._patchEmit(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.prototype?.emit)) {\n this._unwrap(moduleExports.prototype, 'emit');\n }\n }\n );\n\n return [\n new InstrumentationNodeModuleDefinition(\n 'socket.io',\n ['>=3 <5'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.Server?.prototype?.on)) {\n this._unwrap(moduleExports.Server.prototype, 'on');\n }\n this._wrap(\n moduleExports.Server.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n return moduleExports;\n },\n moduleExports => {\n if (isWrapped(moduleExports?.Server?.prototype?.on)) {\n this._unwrap(moduleExports.Server.prototype, 'on');\n }\n return moduleExports;\n },\n [\n broadcastOperatorInstrumentation,\n namespaceInstrumentation,\n socketInstrumentation,\n ]\n ),\n new InstrumentationNodeModuleDefinition(\n 'socket.io',\n ['2'],\n (moduleExports, moduleVersion) => {\n if (moduleExports === undefined || moduleExports === null) {\n return moduleExports;\n }\n if (moduleVersion === undefined) {\n return moduleExports;\n }\n if (isWrapped(moduleExports?.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n this._wrap(\n moduleExports.prototype,\n 'on',\n this._patchOn(moduleVersion)\n );\n return moduleExports;\n },\n (moduleExports, moduleVersion) => {\n if (isWrapped(moduleExports?.prototype?.on)) {\n this._unwrap(moduleExports.prototype, 'on');\n }\n return moduleExports;\n },\n [namespaceInstrumentationLegacy, socketInstrumentationLegacy]\n ),\n ];\n }\n\n override setConfig(config: SocketIoInstrumentationConfig = {}) {\n return super.setConfig(normalizeConfig(config));\n }\n\n private _patchOn(moduleVersion: string) {\n const self = this;\n return (original: Function) => {\n return function (this: any, ev: any, originalListener: Function) {\n if (!self._config.traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self._config.onIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const wrappedListener = function (this: any, ...args: any[]) {\n const eventName = ev;\n const defaultNamespace = '/';\n const namespace = this.name || this.adapter?.nsp?.name;\n const destination =\n namespace === defaultNamespace\n ? eventName\n : `${namespace} ${eventName}`;\n const span: Span = self.tracer.startSpan(\n `${destination} ${MessagingOperationValues.RECEIVE}`,\n {\n kind: SpanKind.CONSUMER,\n attributes: {\n [SemanticAttributes.MESSAGING_SYSTEM]: 'socket.io',\n [SemanticAttributes.MESSAGING_DESTINATION]: namespace,\n [SemanticAttributes.MESSAGING_OPERATION]:\n MessagingOperationValues.RECEIVE,\n [SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]:\n eventName,\n },\n }\n );\n\n if (self._config.onHook) {\n safeExecuteInTheMiddle(\n () =>\n self._config?.onHook?.(span, { moduleVersion, payload: args }),\n e => {\n if (e) self._diag.error('onHook error', e);\n },\n true\n );\n }\n return context.with(trace.setSpan(context.active(), span), () =>\n self.endSpan(() => originalListener.apply(this, arguments), span)\n );\n };\n return original.apply(this, [ev, wrappedListener]);\n };\n };\n }\n\n private endSpan(traced: () => any | Promise<any>, span: Span) {\n try {\n const result = traced();\n if (isPromise(result)) {\n return result.then(\n value => {\n span.end();\n return value;\n },\n err => {\n span.recordException(err);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err?.message,\n });\n span.end();\n throw err;\n }\n );\n } else {\n span.end();\n return result;\n }\n } catch (error: any) {\n span.recordException(error);\n span.setStatus({ code: SpanStatusCode.ERROR, message: error?.message });\n span.end();\n throw error;\n }\n }\n\n private _patchEmit(moduleVersion: string) {\n const self = this;\n return (original: Function) => {\n return function (this: any, ev: any, ...args: any[]) {\n if (!self._config.traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self._config?.emitIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const messagingSystem = 'socket.io';\n const eventName = ev;\n const attributes: any = {\n [SemanticAttributes.MESSAGING_SYSTEM]: messagingSystem,\n [SemanticAttributes.MESSAGING_DESTINATION_KIND]:\n MessagingDestinationKindValues.TOPIC,\n [SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]: eventName,\n };\n\n const rooms = extractRoomsAttributeValue(this);\n if (rooms.length) {\n attributes[SocketIoInstrumentationAttributes.SOCKET_IO_ROOMS] = rooms;\n }\n const namespace =\n this.name || this.adapter?.nsp?.name || this.sockets?.name;\n if (namespace) {\n attributes[SocketIoInstrumentationAttributes.SOCKET_IO_NAMESPACE] =\n namespace;\n attributes[SemanticAttributes.MESSAGING_DESTINATION] = namespace;\n }\n const spanRooms = rooms.length ? `[${rooms.join()}]` : '';\n const span = self.tracer.startSpan(`${namespace}${spanRooms} send`, {\n kind: SpanKind.PRODUCER,\n attributes,\n });\n\n if (self._config.emitHook) {\n safeExecuteInTheMiddle(\n () =>\n self._config.emitHook?.(span, { moduleVersion, payload: args }),\n e => {\n if (e) self._diag.error('emitHook error', e);\n },\n true\n );\n }\n try {\n return context.with(trace.setSpan(context.active(), span), () =>\n original.apply(this, arguments)\n );\n } catch (error: any) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n throw error;\n } finally {\n span.end();\n }\n };\n };\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.37.0";
1
+ export declare const VERSION = "0.39.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.37.0';
20
+ exports.VERSION = '0.39.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.37.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.39.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-socket.io",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "OpenTelemetry automatic instrumentation package for socket.io",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@opentelemetry/api": "^1.3.0",
46
- "@opentelemetry/contrib-test-utils": "^0.37.0",
46
+ "@opentelemetry/contrib-test-utils": "^0.39.0",
47
47
  "@opentelemetry/sdk-trace-base": "^1.8.0",
48
48
  "@types/mocha": "8.2.3",
49
49
  "@types/node": "18.6.5",
@@ -53,14 +53,14 @@
53
53
  "rimraf": "5.0.5",
54
54
  "socket.io": "^4.1.3",
55
55
  "socket.io-client": "^4.1.3",
56
- "test-all-versions": "6.0.0",
56
+ "test-all-versions": "6.1.0",
57
57
  "ts-mocha": "10.0.0",
58
58
  "typescript": "4.4.4"
59
59
  },
60
60
  "dependencies": {
61
- "@opentelemetry/instrumentation": "^0.49.1",
61
+ "@opentelemetry/instrumentation": "^0.51.0",
62
62
  "@opentelemetry/semantic-conventions": "^1.0.0"
63
63
  },
64
64
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io#readme",
65
- "gitHead": "fcea8ca0c83cb1dcd8ac736e5ea4d22ff20dc982"
65
+ "gitHead": "96a87b48934f0afcf1fe637eed6704f35bd8e973"
66
66
  }