@opentelemetry/instrumentation-socket.io 0.41.0 → 0.43.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,7 +1,6 @@
1
1
  import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
2
2
  import { SocketIoInstrumentationConfig } from './types';
3
- export declare class SocketIoInstrumentation extends InstrumentationBase {
4
- protected _config: SocketIoInstrumentationConfig;
3
+ export declare class SocketIoInstrumentation extends InstrumentationBase<SocketIoInstrumentationConfig> {
5
4
  constructor(config?: SocketIoInstrumentationConfig);
6
5
  protected init(): InstrumentationNodeModuleDefinition[];
7
6
  setConfig(config?: SocketIoInstrumentationConfig): void;
@@ -20,6 +20,7 @@ const api_1 = require("@opentelemetry/api");
20
20
  const instrumentation_1 = require("@opentelemetry/instrumentation");
21
21
  const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
22
22
  const AttributeNames_1 = require("./AttributeNames");
23
+ /** @knipignore */
23
24
  const version_1 = require("./version");
24
25
  const utils_1 = require("./utils");
25
26
  const reservedEvents = [
@@ -202,21 +203,17 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
202
203
  return (original) => {
203
204
  return function (ev, originalListener) {
204
205
  var _a;
205
- if (!self._config.traceReserved && reservedEvents.includes(ev)) {
206
+ if (!self.getConfig().traceReserved && reservedEvents.includes(ev)) {
206
207
  return original.apply(this, arguments);
207
208
  }
208
- if ((_a = self._config.onIgnoreEventList) === null || _a === void 0 ? void 0 : _a.includes(ev)) {
209
+ if ((_a = self.getConfig().onIgnoreEventList) === null || _a === void 0 ? void 0 : _a.includes(ev)) {
209
210
  return original.apply(this, arguments);
210
211
  }
211
212
  const wrappedListener = function (...args) {
212
213
  var _a, _b;
213
214
  const eventName = ev;
214
- const defaultNamespace = '/';
215
215
  const namespace = this.name || ((_b = (_a = this.adapter) === null || _a === void 0 ? void 0 : _a.nsp) === null || _b === void 0 ? void 0 : _b.name);
216
- const destination = namespace === defaultNamespace
217
- ? eventName
218
- : `${namespace} ${eventName}`;
219
- const span = self.tracer.startSpan(`${destination} ${semantic_conventions_1.MESSAGINGOPERATIONVALUES_RECEIVE}`, {
216
+ const span = self.tracer.startSpan(`${semantic_conventions_1.MESSAGINGOPERATIONVALUES_RECEIVE} ${namespace}`, {
220
217
  kind: api_1.SpanKind.CONSUMER,
221
218
  attributes: {
222
219
  [semantic_conventions_1.SEMATTRS_MESSAGING_SYSTEM]: 'socket.io',
@@ -225,8 +222,9 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
225
222
  [AttributeNames_1.SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]: eventName,
226
223
  },
227
224
  });
228
- if (self._config.onHook) {
229
- (0, instrumentation_1.safeExecuteInTheMiddle)(() => { var _a, _b; return (_b = (_a = self._config) === null || _a === void 0 ? void 0 : _a.onHook) === null || _b === void 0 ? void 0 : _b.call(_a, span, { moduleVersion, payload: args }); }, e => {
225
+ const { onHook } = self.getConfig();
226
+ if (onHook) {
227
+ (0, instrumentation_1.safeExecuteInTheMiddle)(() => onHook(span, { moduleVersion, payload: args }), e => {
230
228
  if (e)
231
229
  self._diag.error('onHook error', e);
232
230
  }, true);
@@ -270,11 +268,11 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
270
268
  const self = this;
271
269
  return (original) => {
272
270
  return function (ev, ...args) {
273
- var _a, _b, _c, _d, _e;
274
- if (!self._config.traceReserved && reservedEvents.includes(ev)) {
271
+ var _a, _b, _c, _d;
272
+ if (!self.getConfig().traceReserved && reservedEvents.includes(ev)) {
275
273
  return original.apply(this, arguments);
276
274
  }
277
- if ((_b = (_a = self._config) === null || _a === void 0 ? void 0 : _a.emitIgnoreEventList) === null || _b === void 0 ? void 0 : _b.includes(ev)) {
275
+ if ((_a = self.getConfig().emitIgnoreEventList) === null || _a === void 0 ? void 0 : _a.includes(ev)) {
278
276
  return original.apply(this, arguments);
279
277
  }
280
278
  const messagingSystem = 'socket.io';
@@ -288,19 +286,19 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
288
286
  if (rooms.length) {
289
287
  attributes[AttributeNames_1.SocketIoInstrumentationAttributes.SOCKET_IO_ROOMS] = rooms;
290
288
  }
291
- const namespace = this.name || ((_d = (_c = this.adapter) === null || _c === void 0 ? void 0 : _c.nsp) === null || _d === void 0 ? void 0 : _d.name) || ((_e = this.sockets) === null || _e === void 0 ? void 0 : _e.name);
289
+ const namespace = this.name || ((_c = (_b = this.adapter) === null || _b === void 0 ? void 0 : _b.nsp) === null || _c === void 0 ? void 0 : _c.name) || ((_d = this.sockets) === null || _d === void 0 ? void 0 : _d.name);
292
290
  if (namespace) {
293
291
  attributes[AttributeNames_1.SocketIoInstrumentationAttributes.SOCKET_IO_NAMESPACE] =
294
292
  namespace;
295
293
  attributes[semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION] = namespace;
296
294
  }
297
- const spanRooms = rooms.length ? `[${rooms.join()}]` : '';
298
- const span = self.tracer.startSpan(`${namespace}${spanRooms} send`, {
295
+ const span = self.tracer.startSpan(`send ${namespace}`, {
299
296
  kind: api_1.SpanKind.PRODUCER,
300
297
  attributes,
301
298
  });
302
- if (self._config.emitHook) {
303
- (0, instrumentation_1.safeExecuteInTheMiddle)(() => { var _a, _b; return (_b = (_a = self._config).emitHook) === null || _b === void 0 ? void 0 : _b.call(_a, span, { moduleVersion, payload: args }); }, e => {
299
+ const { emitHook } = self.getConfig();
300
+ if (emitHook) {
301
+ (0, instrumentation_1.safeExecuteInTheMiddle)(() => emitHook(span, { moduleVersion, payload: args }), e => {
304
302
  if (e)
305
303
  self._diag.error('emitHook error', e);
306
304
  }, true);
@@ -1 +1 @@
1
- {"version":3,"file":"socket.io.js","sourceRoot":"","sources":["../../src/socket.io.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAC5B,oEAMwC;AACxC,8EAO6C;AAE7C,q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;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;AAtXD,0DAsXC","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 SEMATTRS_MESSAGING_DESTINATION,\n SEMATTRS_MESSAGING_DESTINATION_KIND,\n SEMATTRS_MESSAGING_OPERATION,\n SEMATTRS_MESSAGING_SYSTEM,\n MESSAGINGOPERATIONVALUES_RECEIVE,\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n} from '@opentelemetry/semantic-conventions';\nimport { SocketIoInstrumentationConfig } from './types';\nimport { SocketIoInstrumentationAttributes } from './AttributeNames';\nimport { PACKAGE_NAME, PACKAGE_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(PACKAGE_NAME, PACKAGE_VERSION, normalizeConfig(config));\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 [SEMATTRS_MESSAGING_SYSTEM]: 'socket.io',\n [SEMATTRS_MESSAGING_DESTINATION]: namespace,\n [SEMATTRS_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 [SEMATTRS_MESSAGING_SYSTEM]: messagingSystem,\n [SEMATTRS_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[SEMATTRS_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,8EAO6C;AAE7C,qDAAqE;AACrE,kBAAkB;AAClB,uCAA0D;AAC1D,mCAIiB;AAEjB,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,eAAe;IACf,YAAY;IACZ,eAAe;IACf,aAAa;IACb,gBAAgB;CACjB,CAAC;AAEF,MAAa,uBAAwB,SAAQ,qCAAkD;IAC7F,YAAY,SAAwC,EAAE;QACpD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,IAAA,uBAAe,EAAC,MAAM,CAAC,CAAC,CAAC;IAChE,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;aACtB;YACD,IAAI,aAAa,KAAK,SAAS,EAAE;gBAC/B,OAAO,aAAa,CAAC;aACtB;YACD,IAAI,IAAA,2BAAS,EAAC,MAAA,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,MAAM,0CAAE,SAAS,0CAAE,EAAE,CAAC,EAAE;gBACnD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;aACpD;YACD,IAAI,CAAC,KAAK,CACR,aAAa,CAAC,MAAM,CAA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E,EAAE;oBACtD,IAAI,EAAE,cAAQ,CAAC,QAAQ;oBACvB,UAAU;iBACX,CAAC,CAAC;gBAEH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;gBACtC,IAAI,QAAQ,EAAE;oBACZ,IAAA,wCAAsB,EACpB,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EACtD,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;AA9WD,0DA8WC","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 SEMATTRS_MESSAGING_DESTINATION,\n SEMATTRS_MESSAGING_DESTINATION_KIND,\n SEMATTRS_MESSAGING_OPERATION,\n SEMATTRS_MESSAGING_SYSTEM,\n MESSAGINGOPERATIONVALUES_RECEIVE,\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n} from '@opentelemetry/semantic-conventions';\nimport { SocketIoInstrumentationConfig } from './types';\nimport { SocketIoInstrumentationAttributes } from './AttributeNames';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_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<SocketIoInstrumentationConfig> {\n constructor(config: SocketIoInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, normalizeConfig(config));\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.getConfig().traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self.getConfig().onIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const wrappedListener = function (this: any, ...args: any[]) {\n const eventName = ev;\n const namespace = this.name || this.adapter?.nsp?.name;\n const span: Span = self.tracer.startSpan(\n `${MESSAGINGOPERATIONVALUES_RECEIVE} ${namespace}`,\n {\n kind: SpanKind.CONSUMER,\n attributes: {\n [SEMATTRS_MESSAGING_SYSTEM]: 'socket.io',\n [SEMATTRS_MESSAGING_DESTINATION]: namespace,\n [SEMATTRS_MESSAGING_OPERATION]:\n MESSAGINGOPERATIONVALUES_RECEIVE,\n [SocketIoInstrumentationAttributes.SOCKET_IO_EVENT_NAME]:\n eventName,\n },\n }\n );\n\n const { onHook } = self.getConfig();\n if (onHook) {\n safeExecuteInTheMiddle(\n () => 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.getConfig().traceReserved && reservedEvents.includes(ev)) {\n return original.apply(this, arguments);\n }\n if (self.getConfig().emitIgnoreEventList?.includes(ev)) {\n return original.apply(this, arguments);\n }\n const messagingSystem = 'socket.io';\n const eventName = ev;\n const attributes: any = {\n [SEMATTRS_MESSAGING_SYSTEM]: messagingSystem,\n [SEMATTRS_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[SEMATTRS_MESSAGING_DESTINATION] = namespace;\n }\n const span = self.tracer.startSpan(`send ${namespace}`, {\n kind: SpanKind.PRODUCER,\n attributes,\n });\n\n const { emitHook } = self.getConfig();\n if (emitHook) {\n safeExecuteInTheMiddle(\n () => 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,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.41.0";
1
+ export declare const PACKAGE_VERSION = "0.43.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-socket.io";
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.41.0';
20
+ exports.PACKAGE_VERSION = '0.43.0';
21
21
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-socket.io';
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,0CAA0C,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.41.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-socket.io';\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,0CAA0C,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.43.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-socket.io';\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-socket.io",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "OpenTelemetry instrumentation for `socket.io` messaging server implementation for Socket.IO communication",
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
- "test": "ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
9
+ "test": "mocha --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
10
10
  "test-all-versions": "tav",
11
11
  "tdd": "npm run test -- --watch-extensions ts --watch",
12
12
  "clean": "rimraf build/*",
@@ -44,24 +44,22 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@opentelemetry/api": "^1.3.0",
47
- "@opentelemetry/contrib-test-utils": "^0.40.0",
47
+ "@opentelemetry/contrib-test-utils": "^0.42.0",
48
48
  "@opentelemetry/sdk-trace-base": "^1.8.0",
49
49
  "@types/mocha": "8.2.3",
50
- "@types/node": "18.6.5",
50
+ "@types/node": "18.18.14",
51
51
  "expect": "27.4.2",
52
- "mocha": "7.2.0",
53
52
  "nyc": "15.1.0",
54
- "rimraf": "5.0.5",
53
+ "rimraf": "5.0.10",
55
54
  "socket.io": "^4.1.3",
56
55
  "socket.io-client": "^4.1.3",
57
56
  "test-all-versions": "6.1.0",
58
- "ts-mocha": "10.0.0",
59
57
  "typescript": "4.4.4"
60
58
  },
61
59
  "dependencies": {
62
- "@opentelemetry/instrumentation": "^0.52.0",
63
- "@opentelemetry/semantic-conventions": "^1.22.0"
60
+ "@opentelemetry/instrumentation": "^0.54.0",
61
+ "@opentelemetry/semantic-conventions": "^1.27.0"
64
62
  },
65
63
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io#readme",
66
- "gitHead": "ad8436d6a4174f2288cb939080cd4e74da94b0d7"
64
+ "gitHead": "7633caee19a7f04c5cc5e191d1ae7745ac3739f1"
67
65
  }