@moostjs/otel 0.6.25 → 0.6.27

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/README.md CHANGED
@@ -8,6 +8,8 @@ OpenTelemetry integration for [Moost](https://moost.org). Provides automatic tra
8
8
  npm install @moostjs/otel @opentelemetry/api @opentelemetry/sdk-trace-base
9
9
  ```
10
10
 
11
+ Note: `@moostjs/event-http` is a required peer dependency — install it even if your app only handles CLI or workflow events.
12
+
11
13
  ## Quick Start
12
14
 
13
15
  ```ts
@@ -22,7 +24,7 @@ enableOtelForMoost()
22
24
  - `useOtelContext()` — Access tracing utilities (span, propagation headers, custom attributes).
23
25
  - `useTrace()` — Get the OpenTelemetry `trace` API.
24
26
  - `useSpan()` — Get the current event's root span.
25
- - `useOtelPropagation()` — Get W3C trace-context headers for outgoing requests.
27
+ - `useOtelPropagation()` — Get trace-context propagation data (span context + headers) for outgoing requests.
26
28
 
27
29
  ## Decorators
28
30
 
package/dist/index.cjs CHANGED
@@ -195,13 +195,13 @@ const tracer = _opentelemetry_api.trace.getTracer("moost-tracer");
195
195
  if (eventType === "init") return cb();
196
196
  const { registerSpan } = useOtelContext();
197
197
  let span = _opentelemetry_api.trace.getActiveSpan();
198
- if (eventType === "HTTP") this.patchRsponse();
198
+ if (eventType === _moostjs_event_http.httpKind.kind) this.patchRsponse();
199
199
  else span = tracer.startSpan(`${eventType} Event`);
200
200
  if (span) {
201
201
  registerSpan(span);
202
202
  return this.withSpan(span, cb, {
203
203
  withMetrics: true,
204
- endSpan: eventType !== "HTTP"
204
+ endSpan: eventType !== _moostjs_event_http.httpKind.kind
205
205
  });
206
206
  }
207
207
  return cb();
@@ -246,7 +246,7 @@ const tracer = _opentelemetry_api.trace.getTracer("moost-tracer");
246
246
  const chm = this.getControllerHandlerMeta();
247
247
  const span = getSpan();
248
248
  if (span) {
249
- if (this.getEventType() === "HTTP") {
249
+ if (this.getEventType() === _moostjs_event_http.httpKind.kind) {
250
250
  const req = this.getRequest();
251
251
  span.updateName(`${req?.method || ""} ${req?.url}`);
252
252
  }
@@ -259,7 +259,7 @@ const tracer = _opentelemetry_api.trace.getTracer("moost-tracer");
259
259
  const span = getSpan();
260
260
  if (span) {
261
261
  span.setAttributes(chm.attrs);
262
- if (chm.attrs["moost.event_type"] === "HTTP") span.updateName(`${this.getRequest()?.method || ""} ${_route || "<unresolved>"}`);
262
+ if (chm.attrs["moost.event_type"] === _moostjs_event_http.httpKind.kind) span.updateName(`${this.getRequest()?.method || ""} ${_route || "<unresolved>"}`);
263
263
  else span.updateName(`${chm.attrs["moost.event_type"]} ${_route || "<unresolved>"}`);
264
264
  }
265
265
  }
@@ -294,7 +294,7 @@ const tracer = _opentelemetry_api.trace.getTracer("moost-tracer");
294
294
  "moost.event_type": a["moost.event_type"],
295
295
  "moost.is_error": error ? 1 : 0
296
296
  };
297
- if (a["moost.event_type"] === "HTTP") {
297
+ if (a["moost.event_type"] === _moostjs_event_http.httpKind.kind) {
298
298
  if (!attrs.route) attrs.route = this.getRequest()?.url || "";
299
299
  attrs["http.status_code"] = this.getResponse()?._statusCode || 0;
300
300
  attrs["moost.is_error"] = attrs["moost.is_error"] || attrs["http.status_code"] > 399 ? 1 : 0;
package/dist/index.mjs CHANGED
@@ -194,13 +194,13 @@ const tracer = trace.getTracer("moost-tracer");
194
194
  if (eventType === "init") return cb();
195
195
  const { registerSpan } = useOtelContext();
196
196
  let span = trace.getActiveSpan();
197
- if (eventType === "HTTP") this.patchRsponse();
197
+ if (eventType === httpKind.kind) this.patchRsponse();
198
198
  else span = tracer.startSpan(`${eventType} Event`);
199
199
  if (span) {
200
200
  registerSpan(span);
201
201
  return this.withSpan(span, cb, {
202
202
  withMetrics: true,
203
- endSpan: eventType !== "HTTP"
203
+ endSpan: eventType !== httpKind.kind
204
204
  });
205
205
  }
206
206
  return cb();
@@ -245,7 +245,7 @@ const tracer = trace.getTracer("moost-tracer");
245
245
  const chm = this.getControllerHandlerMeta();
246
246
  const span = getSpan();
247
247
  if (span) {
248
- if (this.getEventType() === "HTTP") {
248
+ if (this.getEventType() === httpKind.kind) {
249
249
  const req = this.getRequest();
250
250
  span.updateName(`${req?.method || ""} ${req?.url}`);
251
251
  }
@@ -258,7 +258,7 @@ const tracer = trace.getTracer("moost-tracer");
258
258
  const span = getSpan();
259
259
  if (span) {
260
260
  span.setAttributes(chm.attrs);
261
- if (chm.attrs["moost.event_type"] === "HTTP") span.updateName(`${this.getRequest()?.method || ""} ${_route || "<unresolved>"}`);
261
+ if (chm.attrs["moost.event_type"] === httpKind.kind) span.updateName(`${this.getRequest()?.method || ""} ${_route || "<unresolved>"}`);
262
262
  else span.updateName(`${chm.attrs["moost.event_type"]} ${_route || "<unresolved>"}`);
263
263
  }
264
264
  }
@@ -293,7 +293,7 @@ const tracer = trace.getTracer("moost-tracer");
293
293
  "moost.event_type": a["moost.event_type"],
294
294
  "moost.is_error": error ? 1 : 0
295
295
  };
296
- if (a["moost.event_type"] === "HTTP") {
296
+ if (a["moost.event_type"] === httpKind.kind) {
297
297
  if (!attrs.route) attrs.route = this.getRequest()?.url || "";
298
298
  attrs["http.status_code"] = this.getResponse()?._statusCode || 0;
299
299
  attrs["moost.is_error"] = attrs["moost.is_error"] || attrs["http.status_code"] > 399 ? 1 : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moostjs/otel",
3
- "version": "0.6.25",
3
+ "version": "0.6.27",
4
4
  "description": "@moostjs/otel",
5
5
  "keywords": [
6
6
  "composables",
@@ -45,9 +45,9 @@
45
45
  "vitest": "3.2.4"
46
46
  },
47
47
  "peerDependencies": {
48
- "@wooksjs/event-core": "^0.7.17",
49
- "moost": "^0.6.25",
50
- "@moostjs/event-http": "^0.6.25"
48
+ "@wooksjs/event-core": "^0.7.19",
49
+ "@moostjs/event-http": "^0.6.27",
50
+ "moost": "^0.6.27"
51
51
  },
52
52
  "scripts": {
53
53
  "pub": "pnpm publish --access public",