@moostjs/otel 0.4.13 → 0.4.14

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,6 +214,9 @@ class SpanInjector extends moost.ContextInjector {
214
214
  if (method === 'WF_STEP') {
215
215
  return;
216
216
  }
217
+ if (method === '__SYSTEM__') {
218
+ return;
219
+ }
217
220
  if (name === 'Handler:not_found') {
218
221
  const chm = this.getControllerHandlerMeta();
219
222
  this.startEventMetrics(chm.attrs, route);
@@ -222,7 +225,7 @@ class SpanInjector extends moost.ContextInjector {
222
225
  const _route = moost.useAsyncEventContext().store('otel').get('route');
223
226
  const chm = this.getControllerHandlerMeta();
224
227
  if (!chm.ignoreMeter) {
225
- this.startEventMetrics(chm.attrs, route);
228
+ this.startEventMetrics(chm.attrs, _route);
226
229
  }
227
230
  const { getSpan } = useOtelContext();
228
231
  const span = getSpan();
@@ -271,7 +274,7 @@ class SpanInjector extends moost.ContextInjector {
271
274
  if (ret && ret instanceof Promise) {
272
275
  ret
273
276
  .then(r => {
274
- endSpan();
277
+ endSpan(r instanceof Error ? r : undefined);
275
278
  return r;
276
279
  })
277
280
  .catch(error => {
@@ -279,7 +282,7 @@ class SpanInjector extends moost.ContextInjector {
279
282
  });
280
283
  }
281
284
  else {
282
- endSpan();
285
+ endSpan(ret instanceof Error ? ret : undefined);
283
286
  }
284
287
  }
285
288
  return ret;
@@ -288,16 +291,15 @@ class SpanInjector extends moost.ContextInjector {
288
291
  if (a['moost.event_type'] === 'HTTP') {
289
292
  const req = this.getRequest();
290
293
  const attrs = {
291
- ...a,
292
- route,
293
- url: req?.url,
294
+ 'route': route || req?.url,
295
+ 'moost.event_type': a['moost.event_type'],
294
296
  };
295
297
  this.metrics.httpRequestCount.add(1, attrs);
296
298
  this.metrics.httpActiveRequests.add(1, attrs);
297
299
  }
298
300
  const attrs = {
299
- ...a,
300
301
  route,
302
+ 'moost.event_type': a['moost.event_type'],
301
303
  };
302
304
  this.metrics.moostEventCount.add(1, attrs);
303
305
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -308,9 +310,8 @@ class SpanInjector extends moost.ContextInjector {
308
310
  const req = this.getRequest();
309
311
  const res = this.getResponse();
310
312
  const attrs = {
311
- ...a,
312
- route,
313
- url: req?.url,
313
+ 'route': route || req?.url,
314
+ 'moost.event_type': a['moost.event_type'],
314
315
  };
315
316
  this.metrics.httpActiveRequests.add(-1, attrs);
316
317
  if (error) {
@@ -321,8 +322,8 @@ class SpanInjector extends moost.ContextInjector {
321
322
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
322
323
  }
323
324
  const attrs = {
324
- ...a,
325
325
  route,
326
+ 'moost.event_type': a['moost.event_type'],
326
327
  };
327
328
  this.metrics.moostActiveEvents.add(-1, attrs);
328
329
  if (error) {
package/dist/index.mjs CHANGED
@@ -212,6 +212,9 @@ class SpanInjector extends ContextInjector {
212
212
  if (method === 'WF_STEP') {
213
213
  return;
214
214
  }
215
+ if (method === '__SYSTEM__') {
216
+ return;
217
+ }
215
218
  if (name === 'Handler:not_found') {
216
219
  const chm = this.getControllerHandlerMeta();
217
220
  this.startEventMetrics(chm.attrs, route);
@@ -220,7 +223,7 @@ class SpanInjector extends ContextInjector {
220
223
  const _route = useAsyncEventContext$1().store('otel').get('route');
221
224
  const chm = this.getControllerHandlerMeta();
222
225
  if (!chm.ignoreMeter) {
223
- this.startEventMetrics(chm.attrs, route);
226
+ this.startEventMetrics(chm.attrs, _route);
224
227
  }
225
228
  const { getSpan } = useOtelContext();
226
229
  const span = getSpan();
@@ -269,7 +272,7 @@ class SpanInjector extends ContextInjector {
269
272
  if (ret && ret instanceof Promise) {
270
273
  ret
271
274
  .then(r => {
272
- endSpan();
275
+ endSpan(r instanceof Error ? r : undefined);
273
276
  return r;
274
277
  })
275
278
  .catch(error => {
@@ -277,7 +280,7 @@ class SpanInjector extends ContextInjector {
277
280
  });
278
281
  }
279
282
  else {
280
- endSpan();
283
+ endSpan(ret instanceof Error ? ret : undefined);
281
284
  }
282
285
  }
283
286
  return ret;
@@ -286,16 +289,15 @@ class SpanInjector extends ContextInjector {
286
289
  if (a['moost.event_type'] === 'HTTP') {
287
290
  const req = this.getRequest();
288
291
  const attrs = {
289
- ...a,
290
- route,
291
- url: req?.url,
292
+ 'route': route || req?.url,
293
+ 'moost.event_type': a['moost.event_type'],
292
294
  };
293
295
  this.metrics.httpRequestCount.add(1, attrs);
294
296
  this.metrics.httpActiveRequests.add(1, attrs);
295
297
  }
296
298
  const attrs = {
297
- ...a,
298
299
  route,
300
+ 'moost.event_type': a['moost.event_type'],
299
301
  };
300
302
  this.metrics.moostEventCount.add(1, attrs);
301
303
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -306,9 +308,8 @@ class SpanInjector extends ContextInjector {
306
308
  const req = this.getRequest();
307
309
  const res = this.getResponse();
308
310
  const attrs = {
309
- ...a,
310
- route,
311
- url: req?.url,
311
+ 'route': route || req?.url,
312
+ 'moost.event_type': a['moost.event_type'],
312
313
  };
313
314
  this.metrics.httpActiveRequests.add(-1, attrs);
314
315
  if (error) {
@@ -319,8 +320,8 @@ class SpanInjector extends ContextInjector {
319
320
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
320
321
  }
321
322
  const attrs = {
322
- ...a,
323
323
  route,
324
+ 'moost.event_type': a['moost.event_type'],
324
325
  };
325
326
  this.metrics.moostActiveEvents.add(-1, attrs);
326
327
  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.14",
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.14"
43
43
  }
44
44
  }