@moostjs/otel 0.4.12 → 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
@@ -210,7 +210,13 @@ class SpanInjector extends moost.ContextInjector {
210
210
  },
211
211
  };
212
212
  }
213
- hook(name, route) {
213
+ hook(method, name, route) {
214
+ if (method === 'WF_STEP') {
215
+ return;
216
+ }
217
+ if (method === '__SYSTEM__') {
218
+ return;
219
+ }
214
220
  if (name === 'Handler:not_found') {
215
221
  const chm = this.getControllerHandlerMeta();
216
222
  this.startEventMetrics(chm.attrs, route);
@@ -219,7 +225,7 @@ class SpanInjector extends moost.ContextInjector {
219
225
  const _route = moost.useAsyncEventContext().store('otel').get('route');
220
226
  const chm = this.getControllerHandlerMeta();
221
227
  if (!chm.ignoreMeter) {
222
- this.startEventMetrics(chm.attrs, route);
228
+ this.startEventMetrics(chm.attrs, _route);
223
229
  }
224
230
  const { getSpan } = useOtelContext();
225
231
  const span = getSpan();
@@ -268,7 +274,7 @@ class SpanInjector extends moost.ContextInjector {
268
274
  if (ret && ret instanceof Promise) {
269
275
  ret
270
276
  .then(r => {
271
- endSpan();
277
+ endSpan(r instanceof Error ? r : undefined);
272
278
  return r;
273
279
  })
274
280
  .catch(error => {
@@ -276,7 +282,7 @@ class SpanInjector extends moost.ContextInjector {
276
282
  });
277
283
  }
278
284
  else {
279
- endSpan();
285
+ endSpan(ret instanceof Error ? ret : undefined);
280
286
  }
281
287
  }
282
288
  return ret;
@@ -285,16 +291,15 @@ class SpanInjector extends moost.ContextInjector {
285
291
  if (a['moost.event_type'] === 'HTTP') {
286
292
  const req = this.getRequest();
287
293
  const attrs = {
288
- ...a,
289
- route,
290
- url: req?.url,
294
+ 'route': route || req?.url,
295
+ 'moost.event_type': a['moost.event_type'],
291
296
  };
292
297
  this.metrics.httpRequestCount.add(1, attrs);
293
298
  this.metrics.httpActiveRequests.add(1, attrs);
294
299
  }
295
300
  const attrs = {
296
- ...a,
297
301
  route,
302
+ 'moost.event_type': a['moost.event_type'],
298
303
  };
299
304
  this.metrics.moostEventCount.add(1, attrs);
300
305
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -305,9 +310,8 @@ class SpanInjector extends moost.ContextInjector {
305
310
  const req = this.getRequest();
306
311
  const res = this.getResponse();
307
312
  const attrs = {
308
- ...a,
309
- route,
310
- url: req?.url,
313
+ 'route': route || req?.url,
314
+ 'moost.event_type': a['moost.event_type'],
311
315
  };
312
316
  this.metrics.httpActiveRequests.add(-1, attrs);
313
317
  if (error) {
@@ -318,8 +322,8 @@ class SpanInjector extends moost.ContextInjector {
318
322
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
319
323
  }
320
324
  const attrs = {
321
- ...a,
322
325
  route,
326
+ 'moost.event_type': a['moost.event_type'],
323
327
  };
324
328
  this.metrics.moostActiveEvents.add(-1, attrs);
325
329
  if (error) {
package/dist/index.d.ts CHANGED
@@ -210,8 +210,8 @@ declare class SpanInjector extends ContextInjector<TContextInjectorHook> {
210
210
  };
211
211
  with<T>(name: TContextInjectorHook, attributes: TAttributes, cb: () => T): T;
212
212
  with<T>(name: TContextInjectorHook, cb: () => T): T;
213
- patchRsponse(): void;
214
- startEvent<T>(eventType: string, cb: () => T): T;
213
+ protected patchRsponse(): void;
214
+ protected startEvent<T>(eventType: string, cb: () => T): T;
215
215
  getEventType(): string;
216
216
  getIgnoreSpan(): boolean | undefined;
217
217
  getControllerHandlerMeta(): {
@@ -228,7 +228,7 @@ declare class SpanInjector extends ContextInjector<TContextInjectorHook> {
228
228
  'moost.event_type': string;
229
229
  };
230
230
  };
231
- hook(name: 'Handler:not_found' | 'Handler:routed' | 'Controller:registered', route?: string): void;
231
+ hook(method: string, name: 'Handler:not_found' | 'Handler:routed' | 'Controller:registered', route?: string): void;
232
232
  withSpan<T>(span: Span, cb: () => T, opts: {
233
233
  rootSpan: boolean;
234
234
  endSpan: boolean;
package/dist/index.mjs CHANGED
@@ -208,7 +208,13 @@ class SpanInjector extends ContextInjector {
208
208
  },
209
209
  };
210
210
  }
211
- hook(name, route) {
211
+ hook(method, name, route) {
212
+ if (method === 'WF_STEP') {
213
+ return;
214
+ }
215
+ if (method === '__SYSTEM__') {
216
+ return;
217
+ }
212
218
  if (name === 'Handler:not_found') {
213
219
  const chm = this.getControllerHandlerMeta();
214
220
  this.startEventMetrics(chm.attrs, route);
@@ -217,7 +223,7 @@ class SpanInjector extends ContextInjector {
217
223
  const _route = useAsyncEventContext$1().store('otel').get('route');
218
224
  const chm = this.getControllerHandlerMeta();
219
225
  if (!chm.ignoreMeter) {
220
- this.startEventMetrics(chm.attrs, route);
226
+ this.startEventMetrics(chm.attrs, _route);
221
227
  }
222
228
  const { getSpan } = useOtelContext();
223
229
  const span = getSpan();
@@ -266,7 +272,7 @@ class SpanInjector extends ContextInjector {
266
272
  if (ret && ret instanceof Promise) {
267
273
  ret
268
274
  .then(r => {
269
- endSpan();
275
+ endSpan(r instanceof Error ? r : undefined);
270
276
  return r;
271
277
  })
272
278
  .catch(error => {
@@ -274,7 +280,7 @@ class SpanInjector extends ContextInjector {
274
280
  });
275
281
  }
276
282
  else {
277
- endSpan();
283
+ endSpan(ret instanceof Error ? ret : undefined);
278
284
  }
279
285
  }
280
286
  return ret;
@@ -283,16 +289,15 @@ class SpanInjector extends ContextInjector {
283
289
  if (a['moost.event_type'] === 'HTTP') {
284
290
  const req = this.getRequest();
285
291
  const attrs = {
286
- ...a,
287
- route,
288
- url: req?.url,
292
+ 'route': route || req?.url,
293
+ 'moost.event_type': a['moost.event_type'],
289
294
  };
290
295
  this.metrics.httpRequestCount.add(1, attrs);
291
296
  this.metrics.httpActiveRequests.add(1, attrs);
292
297
  }
293
298
  const attrs = {
294
- ...a,
295
299
  route,
300
+ 'moost.event_type': a['moost.event_type'],
296
301
  };
297
302
  this.metrics.moostEventCount.add(1, attrs);
298
303
  this.metrics.moostActiveEvents.add(1, attrs);
@@ -303,9 +308,8 @@ class SpanInjector extends ContextInjector {
303
308
  const req = this.getRequest();
304
309
  const res = this.getResponse();
305
310
  const attrs = {
306
- ...a,
307
- route,
308
- url: req?.url,
311
+ 'route': route || req?.url,
312
+ 'moost.event_type': a['moost.event_type'],
309
313
  };
310
314
  this.metrics.httpActiveRequests.add(-1, attrs);
311
315
  if (error) {
@@ -316,8 +320,8 @@ class SpanInjector extends ContextInjector {
316
320
  this.metrics.httpResponseCount.add(1, { ...attrs, status: res?._statusCode });
317
321
  }
318
322
  const attrs = {
319
- ...a,
320
323
  route,
324
+ 'moost.event_type': a['moost.event_type'],
321
325
  };
322
326
  this.metrics.moostActiveEvents.add(-1, attrs);
323
327
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/otel",
3
- "version": "0.4.12",
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.12"
42
+ "moost": "0.4.14"
43
43
  }
44
44
  }