@opentelemetry/instrumentation-socket.io 0.46.0 → 0.47.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,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,8CAA4B;AAC5B,0CAAwB;AACxB,mDAAiC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport * from './socket.io';\nexport * from './types';\nexport * from './AttributeNames';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,8CAA4B;AAC5B,0CAAwB;AACxB,mDAAiC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport * from './socket.io';\nexport * from './types';\nexport * from './AttributeNames';\n"]}
@@ -37,134 +37,122 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
37
37
  }
38
38
  init() {
39
39
  const socketInstrumentation = new instrumentation_1.InstrumentationNodeModuleFile('socket.io/dist/socket.js', ['>=3 <5'], (moduleExports, moduleVersion) => {
40
- var _a, _b, _c, _d;
41
40
  if (moduleExports === undefined || moduleExports === null) {
42
41
  return moduleExports;
43
42
  }
44
43
  if (moduleVersion === undefined) {
45
44
  return moduleExports;
46
45
  }
47
- 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)) {
46
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Socket?.prototype?.on)) {
48
47
  this._unwrap(moduleExports.Socket.prototype, 'on');
49
48
  }
50
49
  this._wrap(moduleExports.Socket.prototype, 'on', this._patchOn(moduleVersion));
51
- if ((0, instrumentation_1.isWrapped)((_d = (_c = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Socket) === null || _c === void 0 ? void 0 : _c.prototype) === null || _d === void 0 ? void 0 : _d.emit)) {
50
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Socket?.prototype?.emit)) {
52
51
  this._unwrap(moduleExports.Socket.prototype, 'emit');
53
52
  }
54
53
  this._wrap(moduleExports.Socket.prototype, 'emit', this._patchEmit(moduleVersion));
55
54
  return moduleExports;
56
55
  }, moduleExports => {
57
- var _a, _b, _c, _d;
58
- 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)) {
56
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Socket?.prototype?.on)) {
59
57
  this._unwrap(moduleExports.Socket.prototype, 'on');
60
58
  }
61
- if ((0, instrumentation_1.isWrapped)((_d = (_c = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.Socket) === null || _c === void 0 ? void 0 : _c.prototype) === null || _d === void 0 ? void 0 : _d.emit)) {
59
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Socket?.prototype?.emit)) {
62
60
  this._unwrap(moduleExports.Socket.prototype, 'emit');
63
61
  }
64
62
  return moduleExports;
65
63
  });
66
64
  const broadcastOperatorInstrumentation = new instrumentation_1.InstrumentationNodeModuleFile('socket.io/dist/broadcast-operator.js', ['>=4 <5'], (moduleExports, moduleVersion) => {
67
- var _a, _b;
68
65
  if (moduleExports === undefined || moduleExports === null) {
69
66
  return moduleExports;
70
67
  }
71
68
  if (moduleVersion === undefined) {
72
69
  return moduleExports;
73
70
  }
74
- 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)) {
71
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.BroadcastOperator?.prototype?.emit)) {
75
72
  this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');
76
73
  }
77
74
  this._wrap(moduleExports.BroadcastOperator.prototype, 'emit', this._patchEmit(moduleVersion));
78
75
  return moduleExports;
79
76
  }, moduleExports => {
80
- var _a, _b;
81
- 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)) {
77
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.BroadcastOperator?.prototype?.emit)) {
82
78
  this._unwrap(moduleExports.BroadcastOperator.prototype, 'emit');
83
79
  }
84
80
  return moduleExports;
85
81
  });
86
82
  const namespaceInstrumentation = new instrumentation_1.InstrumentationNodeModuleFile('socket.io/dist/namespace.js', ['<4'], (moduleExports, moduleVersion) => {
87
- var _a, _b;
88
83
  if (moduleExports === undefined || moduleExports === null) {
89
84
  return moduleExports;
90
85
  }
91
86
  if (moduleVersion === undefined) {
92
87
  return moduleExports;
93
88
  }
94
- 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)) {
89
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Namespace?.prototype?.emit)) {
95
90
  this._unwrap(moduleExports.Namespace.prototype, 'emit');
96
91
  }
97
92
  this._wrap(moduleExports.Namespace.prototype, 'emit', this._patchEmit(moduleVersion));
98
93
  return moduleExports;
99
94
  }, moduleExports => {
100
- var _a, _b;
101
- 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)) {
95
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Namespace?.prototype?.emit)) {
102
96
  this._unwrap(moduleExports.Namespace.prototype, 'emit');
103
97
  }
104
98
  });
105
99
  const socketInstrumentationLegacy = new instrumentation_1.InstrumentationNodeModuleFile('socket.io/lib/socket.js', ['2'], (moduleExports, moduleVersion) => {
106
- var _a, _b;
107
100
  if (moduleExports === undefined || moduleExports === null) {
108
101
  return moduleExports;
109
102
  }
110
103
  if (moduleVersion === undefined) {
111
104
  return moduleExports;
112
105
  }
113
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
106
+ if ((0, instrumentation_1.isWrapped)(moduleExports.prototype?.on)) {
114
107
  this._unwrap(moduleExports.prototype, 'on');
115
108
  }
116
109
  this._wrap(moduleExports.prototype, 'on', this._patchOn(moduleVersion));
117
- if ((0, instrumentation_1.isWrapped)((_b = moduleExports.prototype) === null || _b === void 0 ? void 0 : _b.emit)) {
110
+ if ((0, instrumentation_1.isWrapped)(moduleExports.prototype?.emit)) {
118
111
  this._unwrap(moduleExports.prototype, 'emit');
119
112
  }
120
113
  this._wrap(moduleExports.prototype, 'emit', this._patchEmit(moduleVersion));
121
114
  return moduleExports;
122
115
  }, moduleExports => {
123
- var _a, _b;
124
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
116
+ if ((0, instrumentation_1.isWrapped)(moduleExports.prototype?.on)) {
125
117
  this._unwrap(moduleExports.prototype, 'on');
126
118
  }
127
- if ((0, instrumentation_1.isWrapped)((_b = moduleExports.prototype) === null || _b === void 0 ? void 0 : _b.emit)) {
119
+ if ((0, instrumentation_1.isWrapped)(moduleExports.prototype?.emit)) {
128
120
  this._unwrap(moduleExports.prototype, 'emit');
129
121
  }
130
122
  return moduleExports;
131
123
  });
132
124
  const namespaceInstrumentationLegacy = new instrumentation_1.InstrumentationNodeModuleFile('socket.io/lib/namespace.js', ['2'], (moduleExports, moduleVersion) => {
133
- var _a;
134
125
  if (moduleExports === undefined || moduleExports === null) {
135
126
  return moduleExports;
136
127
  }
137
128
  if (moduleVersion === undefined) {
138
129
  return moduleExports;
139
130
  }
140
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.emit)) {
131
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.prototype?.emit)) {
141
132
  this._unwrap(moduleExports.prototype, 'emit');
142
133
  }
143
134
  this._wrap(moduleExports.prototype, 'emit', this._patchEmit(moduleVersion));
144
135
  return moduleExports;
145
136
  }, moduleExports => {
146
- var _a;
147
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.emit)) {
137
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.prototype?.emit)) {
148
138
  this._unwrap(moduleExports.prototype, 'emit');
149
139
  }
150
140
  });
151
141
  return [
152
142
  new instrumentation_1.InstrumentationNodeModuleDefinition('socket.io', ['>=3 <5'], (moduleExports, moduleVersion) => {
153
- var _a, _b;
154
143
  if (moduleExports === undefined || moduleExports === null) {
155
144
  return moduleExports;
156
145
  }
157
146
  if (moduleVersion === undefined) {
158
147
  return moduleExports;
159
148
  }
160
- 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)) {
149
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Server?.prototype?.on)) {
161
150
  this._unwrap(moduleExports.Server.prototype, 'on');
162
151
  }
163
152
  this._wrap(moduleExports.Server.prototype, 'on', this._patchOn(moduleVersion));
164
153
  return moduleExports;
165
154
  }, moduleExports => {
166
- var _a, _b;
167
- 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)) {
155
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.Server?.prototype?.on)) {
168
156
  this._unwrap(moduleExports.Server.prototype, 'on');
169
157
  }
170
158
  return moduleExports;
@@ -174,21 +162,19 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
174
162
  socketInstrumentation,
175
163
  ]),
176
164
  new instrumentation_1.InstrumentationNodeModuleDefinition('socket.io', ['2'], (moduleExports, moduleVersion) => {
177
- var _a;
178
165
  if (moduleExports === undefined || moduleExports === null) {
179
166
  return moduleExports;
180
167
  }
181
168
  if (moduleVersion === undefined) {
182
169
  return moduleExports;
183
170
  }
184
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
171
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.prototype?.on)) {
185
172
  this._unwrap(moduleExports.prototype, 'on');
186
173
  }
187
174
  this._wrap(moduleExports.prototype, 'on', this._patchOn(moduleVersion));
188
175
  return moduleExports;
189
176
  }, (moduleExports, moduleVersion) => {
190
- var _a;
191
- if ((0, instrumentation_1.isWrapped)((_a = moduleExports === null || moduleExports === void 0 ? void 0 : moduleExports.prototype) === null || _a === void 0 ? void 0 : _a.on)) {
177
+ if ((0, instrumentation_1.isWrapped)(moduleExports?.prototype?.on)) {
192
178
  this._unwrap(moduleExports.prototype, 'on');
193
179
  }
194
180
  return moduleExports;
@@ -202,17 +188,15 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
202
188
  const self = this;
203
189
  return (original) => {
204
190
  return function (ev, originalListener) {
205
- var _a;
206
191
  if (!self.getConfig().traceReserved && reservedEvents.includes(ev)) {
207
192
  return original.apply(this, arguments);
208
193
  }
209
- if ((_a = self.getConfig().onIgnoreEventList) === null || _a === void 0 ? void 0 : _a.includes(ev)) {
194
+ if (self.getConfig().onIgnoreEventList?.includes(ev)) {
210
195
  return original.apply(this, arguments);
211
196
  }
212
197
  const wrappedListener = function (...args) {
213
- var _a, _b;
214
198
  const eventName = ev;
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);
199
+ const namespace = this.name || this.adapter?.nsp?.name;
216
200
  const span = self.tracer.startSpan(`${semantic_conventions_1.MESSAGINGOPERATIONVALUES_RECEIVE} ${namespace}`, {
217
201
  kind: api_1.SpanKind.CONSUMER,
218
202
  attributes: {
@@ -246,7 +230,7 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
246
230
  span.recordException(err);
247
231
  span.setStatus({
248
232
  code: api_1.SpanStatusCode.ERROR,
249
- message: err === null || err === void 0 ? void 0 : err.message,
233
+ message: err?.message,
250
234
  });
251
235
  span.end();
252
236
  throw err;
@@ -259,7 +243,7 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
259
243
  }
260
244
  catch (error) {
261
245
  span.recordException(error);
262
- span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error === null || error === void 0 ? void 0 : error.message });
246
+ span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: error?.message });
263
247
  span.end();
264
248
  throw error;
265
249
  }
@@ -268,11 +252,10 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
268
252
  const self = this;
269
253
  return (original) => {
270
254
  return function (ev, ...args) {
271
- var _a, _b, _c, _d;
272
255
  if (!self.getConfig().traceReserved && reservedEvents.includes(ev)) {
273
256
  return original.apply(this, arguments);
274
257
  }
275
- if ((_a = self.getConfig().emitIgnoreEventList) === null || _a === void 0 ? void 0 : _a.includes(ev)) {
258
+ if (self.getConfig().emitIgnoreEventList?.includes(ev)) {
276
259
  return original.apply(this, arguments);
277
260
  }
278
261
  const messagingSystem = 'socket.io';
@@ -286,7 +269,7 @@ class SocketIoInstrumentation extends instrumentation_1.InstrumentationBase {
286
269
  if (rooms.length) {
287
270
  attributes[AttributeNames_1.SocketIoInstrumentationAttributes.SOCKET_IO_ROOMS] = rooms;
288
271
  }
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);
272
+ const namespace = this.name || this.adapter?.nsp?.name || this.sockets?.name;
290
273
  if (namespace) {
291
274
  attributes[AttributeNames_1.SocketIoInstrumentationAttributes.SOCKET_IO_NAMESPACE] =
292
275
  namespace;
@@ -1 +1 @@
1
- {"version":3,"file":"socket.io.js","sourceRoot":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,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
+ {"version":3,"file":"socket.io.js","sourceRoot":"","sources":["../../src/socket.io.ts"],"names":[],"mappings":";;;AA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["/*\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,5 +1,5 @@
1
1
  import { SocketIoInstrumentationConfig } from './types';
2
2
  export declare const isPromise: (value: any) => value is Promise<unknown>;
3
- export declare const normalizeConfig: (config?: SocketIoInstrumentationConfig | undefined) => SocketIoInstrumentationConfig;
3
+ export declare const normalizeConfig: (config?: SocketIoInstrumentationConfig) => SocketIoInstrumentationConfig;
4
4
  export declare const extractRoomsAttributeValue: (self: any) => any[];
5
5
  //# sourceMappingURL=utils.d.ts.map
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractRoomsAttributeValue = exports.normalizeConfig = exports.isPromise = void 0;
4
4
  const isPromise = (value) => {
5
- return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function';
5
+ return typeof value?.then === 'function';
6
6
  };
7
7
  exports.isPromise = isPromise;
8
8
  const normalizeConfig = (config) => {
@@ -17,11 +17,10 @@ const normalizeConfig = (config) => {
17
17
  };
18
18
  exports.normalizeConfig = normalizeConfig;
19
19
  const extractRoomsAttributeValue = (self) => {
20
- var _a, _b;
21
20
  let rooms = self.rooms ||
22
21
  self._rooms ||
23
- ((_a = self.sockets) === null || _a === void 0 ? void 0 : _a._rooms) ||
24
- ((_b = self.sockets) === null || _b === void 0 ? void 0 : _b.rooms) ||
22
+ self.sockets?._rooms ||
23
+ self.sockets?.rooms ||
25
24
  [];
26
25
  // Some of the attributes above are of Set type. Convert it.
27
26
  if (!Array.isArray(rooms)) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAiBO,MAAM,SAAS,GAAG,CAAC,KAAU,EAA6B,EAAE;IACjE,OAAO,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAA,KAAK,UAAU,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,eAAe,GAAG,CAAC,MAAsC,EAAE,EAAE;IACxE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QAC9C,MAAM,CAAC,mBAAmB,GAAG,EAAE,CAAC;KACjC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QAC5C,MAAM,CAAC,iBAAiB,GAAG,EAAE,CAAC;KAC/B;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEK,MAAM,0BAA0B,GAAG,CAAC,IAAS,EAAS,EAAE;;IAC7D,IAAI,KAAK,GACP,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,MAAM;SACX,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAA;SACpB,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,CAAA;QACnB,EAAE,CAAC;IACL,4DAA4D;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAS,KAAK,CAAC,CAAC;KACnC;IACD,+GAA+G;IAC/G,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE;QACjC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACrB;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,0BAA0B,8BAgBrC","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 { SocketIoInstrumentationConfig } from './types';\n\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\nexport const normalizeConfig = (config?: SocketIoInstrumentationConfig) => {\n config = Object.assign({}, config);\n if (!Array.isArray(config.emitIgnoreEventList)) {\n config.emitIgnoreEventList = [];\n }\n if (!Array.isArray(config.onIgnoreEventList)) {\n config.onIgnoreEventList = [];\n }\n return config;\n};\n\nexport const extractRoomsAttributeValue = (self: any): any[] => {\n let rooms =\n self.rooms ||\n self._rooms ||\n self.sockets?._rooms ||\n self.sockets?.rooms ||\n [];\n // Some of the attributes above are of Set type. Convert it.\n if (!Array.isArray(rooms)) {\n rooms = Array.from<string>(rooms);\n }\n // only for v2: this.id is only set for v2. That's to mimic later versions which have this.id in the rooms Set.\n if (rooms.length === 0 && self.id) {\n rooms.push(self.id);\n }\n return rooms;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAiBO,MAAM,SAAS,GAAG,CAAC,KAAU,EAA6B,EAAE;IACjE,OAAO,OAAO,KAAK,EAAE,IAAI,KAAK,UAAU,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEK,MAAM,eAAe,GAAG,CAAC,MAAsC,EAAE,EAAE;IACxE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QAC9C,MAAM,CAAC,mBAAmB,GAAG,EAAE,CAAC;KACjC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE;QAC5C,MAAM,CAAC,iBAAiB,GAAG,EAAE,CAAC;KAC/B;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEK,MAAM,0BAA0B,GAAG,CAAC,IAAS,EAAS,EAAE;IAC7D,IAAI,KAAK,GACP,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO,EAAE,MAAM;QACpB,IAAI,CAAC,OAAO,EAAE,KAAK;QACnB,EAAE,CAAC;IACL,4DAA4D;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACzB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAS,KAAK,CAAC,CAAC;KACnC;IACD,+GAA+G;IAC/G,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE;QACjC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACrB;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,0BAA0B,8BAgBrC","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 { SocketIoInstrumentationConfig } from './types';\n\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\nexport const normalizeConfig = (config?: SocketIoInstrumentationConfig) => {\n config = Object.assign({}, config);\n if (!Array.isArray(config.emitIgnoreEventList)) {\n config.emitIgnoreEventList = [];\n }\n if (!Array.isArray(config.onIgnoreEventList)) {\n config.onIgnoreEventList = [];\n }\n return config;\n};\n\nexport const extractRoomsAttributeValue = (self: any): any[] => {\n let rooms =\n self.rooms ||\n self._rooms ||\n self.sockets?._rooms ||\n self.sockets?.rooms ||\n [];\n // Some of the attributes above are of Set type. Convert it.\n if (!Array.isArray(rooms)) {\n rooms = Array.from<string>(rooms);\n }\n // only for v2: this.id is only set for v2. That's to mimic later versions which have this.id in the rooms Set.\n if (rooms.length === 0 && self.id) {\n rooms.push(self.id);\n }\n return rooms;\n};\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.46.0";
1
+ export declare const PACKAGE_VERSION = "0.47.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.46.0';
20
+ exports.PACKAGE_VERSION = '0.47.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.46.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.47.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-socket.io';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-socket.io",
3
- "version": "0.46.0",
3
+ "version": "0.47.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",
@@ -28,7 +28,7 @@
28
28
  "author": "OpenTelemetry Authors",
29
29
  "license": "Apache-2.0",
30
30
  "engines": {
31
- "node": ">=14"
31
+ "node": "^18.19.0 || >=20.6.0"
32
32
  },
33
33
  "files": [
34
34
  "build/src/**/*.js",
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@opentelemetry/api": "^1.3.0",
46
- "@opentelemetry/contrib-test-utils": "^0.45.0",
47
- "@opentelemetry/sdk-trace-base": "^1.8.0",
48
- "@types/mocha": "8.2.3",
46
+ "@opentelemetry/contrib-test-utils": "^0.46.0",
47
+ "@opentelemetry/sdk-trace-base": "^2.0.0",
48
+ "@types/mocha": "10.0.10",
49
49
  "@types/node": "18.18.14",
50
50
  "expect": "27.4.2",
51
51
  "nyc": "15.1.0",
@@ -53,12 +53,12 @@
53
53
  "socket.io": "^4.1.3",
54
54
  "socket.io-client": "^4.1.3",
55
55
  "test-all-versions": "6.1.0",
56
- "typescript": "4.4.4"
56
+ "typescript": "5.0.4"
57
57
  },
58
58
  "dependencies": {
59
- "@opentelemetry/instrumentation": "^0.57.0",
59
+ "@opentelemetry/instrumentation": "^0.200.0",
60
60
  "@opentelemetry/semantic-conventions": "^1.27.0"
61
61
  },
62
62
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io#readme",
63
- "gitHead": "3ef5205e5353010184c69ff7b9f0f4830f0932de"
63
+ "gitHead": "32abc4c3c01d0e78e10022c74b6805b06e0e1fe7"
64
64
  }