@nifrajs/otel 2.2.0 → 2.4.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.
package/README.md CHANGED
@@ -20,17 +20,17 @@ const app = server()
20
20
 
21
21
  ## What it does per request
22
22
 
23
- - **Continues an inbound trace** — parses the `traceparent` header; reuses its `trace-id` and records
23
+ - **Continues an inbound trace** - parses the `traceparent` header; reuses its `trace-id` and records
24
24
  the inbound span as the parent. No inbound header → starts a fresh trace.
25
25
  - **Opens a span** with HTTP semantic-convention attributes (`http.request.method`, `url.path`,
26
26
  `http.response.status_code`, optional `service.name`), ended on response with duration + status
27
27
  (`error` for 5xx, `ok` otherwise).
28
- - **Exposes `c.trace`** (`{ traceId, spanId, parentSpanId?, sampled, traceparent }`) — spread
28
+ - **Exposes `c.trace`** (`{ traceId, spanId, parentSpanId?, sampled, traceparent }`) - spread
29
29
  `traceHeaders(c.trace)` into any downstream `fetch`/`ctx.api` call to continue the trace.
30
30
  - **Exposes `c.causality`** - a bounded, payload-free request node that survives durable command,
31
31
  event, workflow, projection, and repair seams. `traceHeaders(c.trace, c.causality)` forwards both
32
32
  conventions to a trusted downstream service.
33
- - **Exposes `c.observation`** — integrations can start correctly-parented child observations or
33
+ - **Exposes `c.observation`** - integrations can start correctly-parented child observations or
34
34
  attach an adapter without rebuilding request lifecycle state.
35
35
  - `responseHeader: true` also sets `traceparent` on the response (browser/client correlation).
36
36
 
@@ -70,10 +70,10 @@ interface ObservationAdapter {
70
70
  }
71
71
  ```
72
72
 
73
- - `consoleSpanExporter()` — logs each completed span as one structured line (dev / starting point).
74
- - `tracing({ adapters: [devtoolsAdapter, privateAdapter] })` — fan out the same lifecycle; adapter
73
+ - `consoleSpanExporter()` - logs each completed span as one structured line (dev / starting point).
74
+ - `tracing({ adapters: [devtoolsAdapter, privateAdapter] })` - fan out the same lifecycle; adapter
75
75
  failures are isolated and never alter the response.
76
- - **OpenTelemetry SDK bridge** — a ~10-line adapter maps `NifraSpan` onto a real OTel `Span` from a
76
+ - **OpenTelemetry SDK bridge** - a ~10-line adapter maps `NifraSpan` onto a real OTel `Span` from a
77
77
  `Tracer` (the attribute names already follow OTel conventions, so they pass straight through). Your
78
78
  app depends on `@opentelemetry/*`; `@nifrajs/otel` does not.
79
79
 
@@ -88,7 +88,7 @@ it over hand-rolling traceparent parsing, clocks, error status, or completion gu
88
88
 
89
89
  ## For AI agents
90
90
 
91
- Start with [`LLM.md`](./LLM.md) — this package's contract card (the exports you call + its footguns),
91
+ Start with [`LLM.md`](./LLM.md) - this package's contract card (the exports you call + its footguns),
92
92
  one cheap read instead of the whole corpus. For the wider framework: the repo's
93
93
  [`AGENTS.md`](../../AGENTS.md) is the copy-paste quick reference, and
94
94
  [`llms-full.txt`](../../llms-full.txt) is the full machine-readable corpus. Run `nifra check` as the
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @nifrajs/otel — distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
2
+ * @nifrajs/otel - distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
3
3
  * trace per request, opens an OpenTelemetry-semantic-convention span, and exposes `c.trace` so you
4
4
  * can forward the trace to downstream services with `traceHeaders(c.trace)`. Spans go to a pluggable
5
- * `ObservationAdapter` — bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
5
+ * `ObservationAdapter` - bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
6
6
  * bundled; edge-safe.
7
7
  *
8
8
  * import { tracing, traceHeaders, consoleSpanExporter } from "@nifrajs/otel"
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @nifrajs/otel — distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
2
+ * @nifrajs/otel - distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
3
3
  * trace per request, opens an OpenTelemetry-semantic-convention span, and exposes `c.trace` so you
4
4
  * can forward the trace to downstream services with `traceHeaders(c.trace)`. Spans go to a pluggable
5
- * `ObservationAdapter` — bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
5
+ * `ObservationAdapter` - bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
6
6
  * bundled; edge-safe.
7
7
  *
8
8
  * import { tracing, traceHeaders, consoleSpanExporter } from "@nifrajs/otel"
@@ -41,7 +41,7 @@ export interface ActiveObservation {
41
41
  /** Starts a child that inherits this span's trace identity and sampling decision. */
42
42
  startChild(input: Omit<StartObservation, "parent" | "traceparent">, additionalAdapters?: readonly ObservationAdapter[]): ActiveObservation;
43
43
  /**
44
- * Merge attributes onto the in-flight span — the seam for plugins that learn something mid-request
44
+ * Merge attributes onto the in-flight span - the seam for plugins that learn something mid-request
45
45
  * (an authenticated principal, a feature-flag bucket, a cache verdict) after the span opened.
46
46
  * Silently ignored once the observation has ended (the exported span is immutable).
47
47
  */
package/dist/span.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The span model + exporter seam. Attribute names follow OpenTelemetry HTTP semantic conventions
3
3
  * (`http.request.method`, `url.path`, `http.response.status_code`, …) so a span maps cleanly onto an
4
- * OTel `Span` when bridged — but nothing here depends on the OTel SDK. You supply an
4
+ * OTel `Span` when bridged - but nothing here depends on the OTel SDK. You supply an
5
5
  * {@link ObservationAdapter}
6
6
  * (a ~10-line adapter to `@opentelemetry/api`, or the bundled {@link consoleSpanExporter}).
7
7
  */
@@ -15,7 +15,7 @@ export interface ObservationLink {
15
15
  }
16
16
  /** A completed (or in-flight) server span for one request. */
17
17
  export interface NifraSpan {
18
- /** 32-hex W3C trace id — shared across every span/service in the trace. */
18
+ /** 32-hex W3C trace id - shared across every span/service in the trace. */
19
19
  readonly traceId: string;
20
20
  /** 16-hex id of this span. */
21
21
  readonly spanId: string;
@@ -23,11 +23,11 @@ export interface NifraSpan {
23
23
  readonly parentSpanId?: string;
24
24
  /** Whether the trace is sampled (the W3C flag). */
25
25
  readonly sampled: boolean;
26
- /** Span name — `"<METHOD> <path>"`. */
26
+ /** Span name - `"<METHOD> <path>"`. */
27
27
  readonly name: string;
28
28
  /** Wall-clock start (epoch ms). */
29
29
  readonly startTime: number;
30
- /** Wall-clock end (epoch ms) — set on completion. */
30
+ /** Wall-clock end (epoch ms) - set on completion. */
31
31
  endTime?: number;
32
32
  /** Duration in ms (monotonic). */
33
33
  durationMs?: number;
package/dist/span.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The span model + exporter seam. Attribute names follow OpenTelemetry HTTP semantic conventions
3
3
  * (`http.request.method`, `url.path`, `http.response.status_code`, …) so a span maps cleanly onto an
4
- * OTel `Span` when bridged — but nothing here depends on the OTel SDK. You supply an
4
+ * OTel `Span` when bridged - but nothing here depends on the OTel SDK. You supply an
5
5
  * {@link ObservationAdapter}
6
6
  * (a ~10-line adapter to `@opentelemetry/api`, or the bundled {@link consoleSpanExporter}).
7
7
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * W3C Trace Context — `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
2
+ * W3C Trace Context - `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
3
3
  * wire format for propagating a trace across services, so producing/forwarding it correctly is the
4
4
  * core of distributed tracing regardless of which backend ends up collecting the spans.
5
5
  *
@@ -14,7 +14,7 @@ export interface ParsedTraceparent {
14
14
  readonly sampled: boolean;
15
15
  }
16
16
  /**
17
- * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown — per the spec,
17
+ * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown - per the spec,
18
18
  * a bad header means "start a fresh trace", never an error. Only version `00` is accepted.
19
19
  */
20
20
  export declare function parseTraceparent(header: string | null | undefined): ParsedTraceparent | null;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * W3C Trace Context — `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
2
+ * W3C Trace Context - `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
3
3
  * wire format for propagating a trace across services, so producing/forwarding it correctly is the
4
4
  * core of distributed tracing regardless of which backend ends up collecting the spans.
5
5
  *
@@ -11,7 +11,7 @@ const HEX = /^[0-9a-f]+$/;
11
11
  const ZERO_TRACE = "00000000000000000000000000000000";
12
12
  const ZERO_SPAN = "0000000000000000";
13
13
  /**
14
- * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown — per the spec,
14
+ * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown - per the spec,
15
15
  * a bad header means "start a fresh trace", never an error. Only version `00` is accepted.
16
16
  */
17
17
  export function parseTraceparent(header) {
package/dist/tracing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The `tracing()` plugin — establishes a span per request, propagates W3C trace context, and exposes
2
+ * The `tracing()` plugin - establishes a span per request, propagates W3C trace context, and exposes
3
3
  * `c.trace` for forwarding the trace to downstream services. OpenTelemetry-compatible by wire format
4
4
  * (traceparent) and attribute names (HTTP semantic conventions); the span itself is exported through
5
5
  * your {@link ObservationAdapter} (bridge to the OTel SDK, or log via `consoleSpanExporter`).
@@ -18,7 +18,7 @@ export interface TracingOptions {
18
18
  readonly serviceName?: string;
19
19
  /**
20
20
  * Set the outbound `traceparent` on the RESPONSE too (handy for browser/client correlation).
21
- * Default false — most setups only propagate downstream, not back to the caller.
21
+ * Default false - most setups only propagate downstream, not back to the caller.
22
22
  */
23
23
  readonly responseHeader?: boolean;
24
24
  /**
package/dist/tracing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The `tracing()` plugin — establishes a span per request, propagates W3C trace context, and exposes
2
+ * The `tracing()` plugin - establishes a span per request, propagates W3C trace context, and exposes
3
3
  * `c.trace` for forwarding the trace to downstream services. OpenTelemetry-compatible by wire format
4
4
  * (traceparent) and attribute names (HTTP semantic conventions); the span itself is exported through
5
5
  * your {@link ObservationAdapter} (bridge to the OTel SDK, or log via `consoleSpanExporter`).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nifrajs/otel",
3
- "version": "2.2.0",
4
- "description": "Distributed tracing for nifra — W3C traceparent/tracestate propagation + OpenTelemetry-semantic-convention spans via a pluggable exporter. Bridge to the OpenTelemetry SDK or log spans directly; no SDK bundled. Edge-safe.",
3
+ "version": "2.4.0",
4
+ "description": "Distributed tracing for nifra - W3C traceparent/tracestate propagation + OpenTelemetry-semantic-convention spans via a pluggable exporter. Bridge to the OpenTelemetry SDK or log spans directly; no SDK bundled. Edge-safe.",
5
5
  "keywords": [
6
6
  "bun",
7
7
  "typescript",
@@ -49,7 +49,7 @@
49
49
  "access": "public"
50
50
  },
51
51
  "peerDependencies": {
52
- "@nifrajs/core": "^2.2.0"
52
+ "@nifrajs/core": "^2.4.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@nifrajs/core": "workspace:*"
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @nifrajs/otel — distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
2
+ * @nifrajs/otel - distributed tracing for nifra. The `tracing()` plugin continues (or starts) a W3C
3
3
  * trace per request, opens an OpenTelemetry-semantic-convention span, and exposes `c.trace` so you
4
4
  * can forward the trace to downstream services with `traceHeaders(c.trace)`. Spans go to a pluggable
5
- * `ObservationAdapter` — bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
5
+ * `ObservationAdapter` - bridge to the OpenTelemetry SDK, or log with `consoleSpanExporter`. No SDK
6
6
  * bundled; edge-safe.
7
7
  *
8
8
  * import { tracing, traceHeaders, consoleSpanExporter } from "@nifrajs/otel"
package/src/lifecycle.ts CHANGED
@@ -62,7 +62,7 @@ export interface ActiveObservation {
62
62
  additionalAdapters?: readonly ObservationAdapter[],
63
63
  ): ActiveObservation
64
64
  /**
65
- * Merge attributes onto the in-flight span — the seam for plugins that learn something mid-request
65
+ * Merge attributes onto the in-flight span - the seam for plugins that learn something mid-request
66
66
  * (an authenticated principal, a feature-flag bucket, a cache verdict) after the span opened.
67
67
  * Silently ignored once the observation has ended (the exported span is immutable).
68
68
  */
package/src/span.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The span model + exporter seam. Attribute names follow OpenTelemetry HTTP semantic conventions
3
3
  * (`http.request.method`, `url.path`, `http.response.status_code`, …) so a span maps cleanly onto an
4
- * OTel `Span` when bridged — but nothing here depends on the OTel SDK. You supply an
4
+ * OTel `Span` when bridged - but nothing here depends on the OTel SDK. You supply an
5
5
  * {@link ObservationAdapter}
6
6
  * (a ~10-line adapter to `@opentelemetry/api`, or the bundled {@link consoleSpanExporter}).
7
7
  */
@@ -18,7 +18,7 @@ export interface ObservationLink {
18
18
 
19
19
  /** A completed (or in-flight) server span for one request. */
20
20
  export interface NifraSpan {
21
- /** 32-hex W3C trace id — shared across every span/service in the trace. */
21
+ /** 32-hex W3C trace id - shared across every span/service in the trace. */
22
22
  readonly traceId: string
23
23
  /** 16-hex id of this span. */
24
24
  readonly spanId: string
@@ -26,11 +26,11 @@ export interface NifraSpan {
26
26
  readonly parentSpanId?: string
27
27
  /** Whether the trace is sampled (the W3C flag). */
28
28
  readonly sampled: boolean
29
- /** Span name — `"<METHOD> <path>"`. */
29
+ /** Span name - `"<METHOD> <path>"`. */
30
30
  readonly name: string
31
31
  /** Wall-clock start (epoch ms). */
32
32
  readonly startTime: number
33
- /** Wall-clock end (epoch ms) — set on completion. */
33
+ /** Wall-clock end (epoch ms) - set on completion. */
34
34
  endTime?: number
35
35
  /** Duration in ms (monotonic). */
36
36
  durationMs?: number
@@ -1,5 +1,5 @@
1
1
  /**
2
- * W3C Trace Context — `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
2
+ * W3C Trace Context - `traceparent` parsing/formatting + id generation. This is OpenTelemetry's
3
3
  * wire format for propagating a trace across services, so producing/forwarding it correctly is the
4
4
  * core of distributed tracing regardless of which backend ends up collecting the spans.
5
5
  *
@@ -20,7 +20,7 @@ const ZERO_TRACE = "00000000000000000000000000000000"
20
20
  const ZERO_SPAN = "0000000000000000"
21
21
 
22
22
  /**
23
- * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown — per the spec,
23
+ * Parse a `traceparent` header, or `null` if it's absent/malformed/version-unknown - per the spec,
24
24
  * a bad header means "start a fresh trace", never an error. Only version `00` is accepted.
25
25
  */
26
26
  export function parseTraceparent(header: string | null | undefined): ParsedTraceparent | null {
package/src/tracing.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The `tracing()` plugin — establishes a span per request, propagates W3C trace context, and exposes
2
+ * The `tracing()` plugin - establishes a span per request, propagates W3C trace context, and exposes
3
3
  * `c.trace` for forwarding the trace to downstream services. OpenTelemetry-compatible by wire format
4
4
  * (traceparent) and attribute names (HTTP semantic conventions); the span itself is exported through
5
5
  * your {@link ObservationAdapter} (bridge to the OTel SDK, or log via `consoleSpanExporter`).
@@ -33,7 +33,7 @@ export interface TracingOptions {
33
33
  readonly serviceName?: string
34
34
  /**
35
35
  * Set the outbound `traceparent` on the RESPONSE too (handy for browser/client correlation).
36
- * Default false — most setups only propagate downstream, not back to the caller.
36
+ * Default false - most setups only propagate downstream, not back to the caller.
37
37
  */
38
38
  readonly responseHeader?: boolean
39
39
  /**