@moostjs/otel 0.4.13 → 0.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -214,17 +214,28 @@ class SpanInjector extends moost.ContextInjector {
214
214
  if (method === 'WF_STEP') {
215
215
  return;
216
216
  }
217
+ if (method === '__SYSTEM__') {
218
+ return;
219
+ }
220
+ const { getSpan } = useOtelContext();
217
221
  if (name === 'Handler:not_found') {
218
222
  const chm = this.getControllerHandlerMeta();
223
+ const span = getSpan();
224
+ if (span) {
225
+ const eventType = this.getEventType();
226
+ if (eventType === 'HTTP') {
227
+ const req = this.getRequest();
228
+ span.updateName(`${req?.method || ''} ${req?.url}`);
229
+ }
230
+ }
219
231
  this.startEventMetrics(chm.attrs, route);
220
232
  }
221
233
  else if (name === 'Controller:registered') {
222
234
  const _route = moost.useAsyncEventContext().store('otel').get('route');
223
235
  const chm = this.getControllerHandlerMeta();
224
236
  if (!chm.ignoreMeter) {
225
- this.startEventMetrics(chm.attrs, route);
237
+ this.startEventMetrics(chm.attrs, _route);
226
238
  }
227
- const { getSpan } = useOtelContext();
228
239
  const span = getSpan();
229
240
  if (span) {
230
241
  span.setAttributes(chm.attrs);
@@ -271,7 +282,7 @@ class SpanInjector extends moost.ContextInjector {
271
282
  if (ret && ret instanceof Promise) {
272
283
  ret
273
284
  .then(r => {
274
- endSpan();
285
+ endSpan(r instanceof Error ? r : undefined);
275
286
  return r;
276
287
  })
277
288
  .catch(error => {
@@ -279,7 +290,7 @@ class SpanInjector extends moost.ContextInjector {
279
290
  });
280
291
  }
281
292
  else {
282
- endSpan();
293
+ endSpan(ret instanceof Error ? ret : undefined);
283
294
  }
284
295
  }
285
296
  return ret;
@@ -288,16 +299,15 @@ class SpanInjector extends moost.ContextInjector {
288
299
  if (a['moost.event_type'] === 'HTTP') {
289
300
  const req = this.getRequest();
290
301
  const attrs = {
291
- ...a,
292
- route,
293
- url: req?.url,
302
+ 'route': route || req?.url,
303
+ 'moost.event_type': a['moost.event_type'],
294
304
  };
295
305
  this.metrics.httpRequestCount.add(1, attrs);
296
306
  this.metrics.httpActiveRequests.add(1, attrs);
297
307
  }
298
308
  const attrs = {
299
- ...a,
300
309
  route,
310
+ 'moost.event_type': a['moost.event_type'],
301
311
  };
302
312
  this.metrics.moostEventCount.add(1, attrs);
303
313
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -308,9 +318,8 @@ class SpanInjector extends moost.ContextInjector {
308
318
  const req = this.getRequest();
309
319
  const res = this.getResponse();
310
320
  const attrs = {
311
- ...a,
312
- route,
313
- url: req?.url,
321
+ 'route': route || req?.url,
322
+ 'moost.event_type': a['moost.event_type'],
314
323
  };
315
324
  this.metrics.httpActiveRequests.add(-1, attrs);
316
325
  if (error) {
@@ -321,8 +330,8 @@ class SpanInjector extends moost.ContextInjector {
321
330
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
322
331
  }
323
332
  const attrs = {
324
- ...a,
325
333
  route,
334
+ 'moost.event_type': a['moost.event_type'],
326
335
  };
327
336
  this.metrics.moostActiveEvents.add(-1, attrs);
328
337
  if (error) {
package/dist/index.mjs CHANGED
@@ -212,17 +212,28 @@ class SpanInjector extends ContextInjector {
212
212
  if (method === 'WF_STEP') {
213
213
  return;
214
214
  }
215
+ if (method === '__SYSTEM__') {
216
+ return;
217
+ }
218
+ const { getSpan } = useOtelContext();
215
219
  if (name === 'Handler:not_found') {
216
220
  const chm = this.getControllerHandlerMeta();
221
+ const span = getSpan();
222
+ if (span) {
223
+ const eventType = this.getEventType();
224
+ if (eventType === 'HTTP') {
225
+ const req = this.getRequest();
226
+ span.updateName(`${req?.method || ''} ${req?.url}`);
227
+ }
228
+ }
217
229
  this.startEventMetrics(chm.attrs, route);
218
230
  }
219
231
  else if (name === 'Controller:registered') {
220
232
  const _route = useAsyncEventContext$1().store('otel').get('route');
221
233
  const chm = this.getControllerHandlerMeta();
222
234
  if (!chm.ignoreMeter) {
223
- this.startEventMetrics(chm.attrs, route);
235
+ this.startEventMetrics(chm.attrs, _route);
224
236
  }
225
- const { getSpan } = useOtelContext();
226
237
  const span = getSpan();
227
238
  if (span) {
228
239
  span.setAttributes(chm.attrs);
@@ -269,7 +280,7 @@ class SpanInjector extends ContextInjector {
269
280
  if (ret && ret instanceof Promise) {
270
281
  ret
271
282
  .then(r => {
272
- endSpan();
283
+ endSpan(r instanceof Error ? r : undefined);
273
284
  return r;
274
285
  })
275
286
  .catch(error => {
@@ -277,7 +288,7 @@ class SpanInjector extends ContextInjector {
277
288
  });
278
289
  }
279
290
  else {
280
- endSpan();
291
+ endSpan(ret instanceof Error ? ret : undefined);
281
292
  }
282
293
  }
283
294
  return ret;
@@ -286,16 +297,15 @@ class SpanInjector extends ContextInjector {
286
297
  if (a['moost.event_type'] === 'HTTP') {
287
298
  const req = this.getRequest();
288
299
  const attrs = {
289
- ...a,
290
- route,
291
- url: req?.url,
300
+ 'route': route || req?.url,
301
+ 'moost.event_type': a['moost.event_type'],
292
302
  };
293
303
  this.metrics.httpRequestCount.add(1, attrs);
294
304
  this.metrics.httpActiveRequests.add(1, attrs);
295
305
  }
296
306
  const attrs = {
297
- ...a,
298
307
  route,
308
+ 'moost.event_type': a['moost.event_type'],
299
309
  };
300
310
  this.metrics.moostEventCount.add(1, attrs);
301
311
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -306,9 +316,8 @@ class SpanInjector extends ContextInjector {
306
316
  const req = this.getRequest();
307
317
  const res = this.getResponse();
308
318
  const attrs = {
309
- ...a,
310
- route,
311
- url: req?.url,
319
+ 'route': route || req?.url,
320
+ 'moost.event_type': a['moost.event_type'],
312
321
  };
313
322
  this.metrics.httpActiveRequests.add(-1, attrs);
314
323
  if (error) {
@@ -319,8 +328,8 @@ class SpanInjector extends ContextInjector {
319
328
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
320
329
  }
321
330
  const attrs = {
322
- ...a,
323
331
  route,
332
+ 'moost.event_type': a['moost.event_type'],
324
333
  };
325
334
  this.metrics.moostActiveEvents.add(-1, attrs);
326
335
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/otel",
3
- "version": "0.4.13",
3
+ "version": "0.4.15",
4
4
  "description": "@moostjs/otel",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -39,6 +39,6 @@
39
39
  "dependencies": {
40
40
  "@opentelemetry/api": "^1.9.0",
41
41
  "@opentelemetry/sdk-trace-base": "^1.25.1",
42
- "moost": "0.4.13"
42
+ "moost": "0.4.15"
43
43
  }
44
44
  }