workers-axiom 0.1.0 → 0.1.1

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
@@ -1,5 +1,8 @@
1
1
  # workers-axiom
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/workers-axiom.svg)](https://www.npmjs.com/package/workers-axiom)
4
+ [![license](https://img.shields.io/npm/l/workers-axiom.svg)](./LICENSE)
5
+
3
6
  Structured logging, tracing, and metrics for Cloudflare Workers, with an Axiom tail-worker sink.
4
7
 
5
8
  > **Status:** used internally by Sapt. Open source, MIT-licensed. PRs welcome, support is best-effort.
@@ -1,4 +1,4 @@
1
- export { LogLevel, createLogger, noopLogger, withTrace, type KVLike, type LogContext, type Logger, type LoggerOptions, type WithTraceOptions, } from './logger';
2
- export type { SpanOptions, TraceContext } from './tracing';
3
- export { SPAN_EVENT_TYPE, SUMMARY_PROPERTIES_TYPE, isSpanEvent, parseTraceparent, formatTraceparent, type AttributeValue, type SpanEvent, type SpanKind, type SpanStatus, type TraceParent, } from '../protocol';
1
+ export { LogLevel, createLogger, noopLogger, withTrace, type KVLike, type LogContext, type Logger, type LoggerOptions, type LoggerSpanHandle, type WithTraceOptions, } from './logger.js';
2
+ export type { Exit, SpanHandle, SpanOptions, TraceContext } from './tracing/index.js';
3
+ export { SPAN_EVENT_TYPE, SUMMARY_PROPERTIES_TYPE, isSpanEvent, parseTraceparent, formatTraceparent, type AttributeValue, type SpanEvent, type SpanKind, type SpanStatus, type TraceParent, } from '../protocol/index.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAA;AAEjB,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAI1D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,EACT,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAA;AAEpB,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIrF,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,sBAAsB,CAAA"}
@@ -1,5 +1,5 @@
1
- export { LogLevel, createLogger, noopLogger, withTrace, } from './logger';
1
+ export { LogLevel, createLogger, noopLogger, withTrace, } from './logger.js';
2
2
  // Re-export wire-format types that consumers commonly need when extending
3
3
  // the producer (custom attributes, propagation helpers in middleware, etc.).
4
- export { SPAN_EVENT_TYPE, SUMMARY_PROPERTIES_TYPE, isSpanEvent, parseTraceparent, formatTraceparent, } from '../protocol';
4
+ export { SPAN_EVENT_TYPE, SUMMARY_PROPERTIES_TYPE, isSpanEvent, parseTraceparent, formatTraceparent, } from '../protocol/index.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/producer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,GAMV,MAAM,UAAU,CAAA;AAIjB,0EAA0E;AAC1E,6EAA6E;AAC7E,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/producer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,GAOV,MAAM,aAAa,CAAA;AAIpB,0EAA0E;AAC1E,6EAA6E;AAC7E,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,GAMlB,MAAM,sBAAsB,CAAA"}
@@ -1,5 +1,5 @@
1
- import { type AttributeValue, type SpanKind } from '../protocol';
2
- import { type SpanOptions, type TraceContext } from './tracing';
1
+ import { type AttributeValue, type SpanKind } from '../protocol/index.js';
2
+ import { type Exit, type SpanOptions, type TraceContext } from './tracing/index.js';
3
3
  /**
4
4
  * Bag of correlation fields (requestId, actorId, etc.). Has no semantic meaning
5
5
  * to the logger — it's just merged into emitted JSON. First-class metadata
@@ -39,7 +39,21 @@ export interface Logger {
39
39
  * creation) are recorded as `status: 'ok'` — they're expected user-facing
40
40
  * failures, not span failures.
41
41
  */
42
- span<T>(name: string, options: SpanOptions, fn: (logger: Logger) => Promise<T>): Promise<T>;
42
+ withSpan<T>(name: string, options: SpanOptions, fn: (logger: Logger) => Promise<T>): Promise<T>;
43
+ /**
44
+ * Open a span whose lifetime is settled later. Use when the span's duration
45
+ * doesn't align with a function scope (typically driven by external
46
+ * callbacks like a streaming API's `onFinish`/`onError`/`onAbort`).
47
+ *
48
+ * Returns a handle bundling a `Logger` already bound to the new span (so
49
+ * logs/metrics emitted via it correlate automatically) and an `end(exit)`
50
+ * method that settles the span with an `Exit` outcome. `end` is idempotent —
51
+ * first call wins, later calls are ignored.
52
+ *
53
+ * Prefer `withSpan` when the span's lifetime aligns with a function — that
54
+ * form can't leak.
55
+ */
56
+ startSpan(name: string, options: SpanOptions): LoggerSpanHandle;
43
57
  /**
44
58
  * Returns headers to propagate the current trace context on outbound calls.
45
59
  * Always include the result on outbound `fetch` calls (including service
@@ -47,6 +61,13 @@ export interface Logger {
47
61
  */
48
62
  tracingHeaders(): Headers;
49
63
  }
64
+ /** Handle returned by `Logger.startSpan` — span-bound logger plus `end(exit)`. */
65
+ export interface LoggerSpanHandle {
66
+ /** Child logger bound to the new span; pass into work that should correlate. */
67
+ readonly logger: Logger;
68
+ /** Settle the span. Idempotent: first call wins. */
69
+ end(exit: Exit<unknown>): void;
70
+ }
50
71
  export declare const LogLevel: {
51
72
  readonly debug: 0;
52
73
  readonly info: 1;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/producer/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAInB,KAAK,QAAQ,EAEd,MAAM,aAAa,CAAA;AACpB,OAAO,EAIL,KAAK,WAAW,EAEhB,KAAK,YAAY,EAClB,MAAM,WAAW,CAAA;AAElB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD,MAAM,WAAW,MAAM;IACrB,2BAA2B;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IACtC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;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AA;IACf,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CAC5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,OAAO,EAAE,gBAAgB,EACzB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAClC,KAAK,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CAAE,GACrE,OAAO,CAAC,CAAC,CAAC,CAWZ;AAED,kFAAkF;AAClF,eAAO,MAAM,UAAU,EAAE,MAgBxB,CAAA"}
@@ -1,5 +1,5 @@
1
- import { formatTraceparent, generateTraceId, parseTraceparent, SUMMARY_PROPERTIES_TYPE, } from '../protocol';
2
- import { createClock, runSpan, toSpanException, } from './tracing';
1
+ import { formatTraceparent, generateTraceId, parseTraceparent, SUMMARY_PROPERTIES_TYPE, } from '../protocol/index.js';
2
+ import { createClock, runSpan, startSpan, toSpanException, } from './tracing/index.js';
3
3
  const BASE_LOG_LEVEL_KEY = 'logLevel';
4
4
  export const LogLevel = {
5
5
  debug: 0,
@@ -117,7 +117,7 @@ function _createLogger(options, clock, trace) {
117
117
  child(newContext) {
118
118
  return _createLogger({ ...options, context: { ...context, ...newContext } }, clock, trace);
119
119
  },
120
- async span(name, spanOptions, fn) {
120
+ async withSpan(name, spanOptions, fn) {
121
121
  return runSpan({
122
122
  parent: trace,
123
123
  resource: { service, environment },
@@ -129,6 +129,21 @@ function _createLogger(options, clock, trace) {
129
129
  onUnexpectedError: (err, childCtx) => _createLogger(options, clock, childCtx).error(err, `span "${name}" failed`),
130
130
  });
131
131
  },
132
+ startSpan(name, spanOptions) {
133
+ const handle = startSpan({
134
+ parent: trace,
135
+ resource: { service, environment },
136
+ name,
137
+ options: spanOptions,
138
+ clock,
139
+ isExpectedError,
140
+ onUnexpectedError: (err, childCtx) => _createLogger(options, clock, childCtx).error(err, `span "${name}" failed`),
141
+ });
142
+ return {
143
+ logger: _createLogger(options, clock, handle.trace),
144
+ end: handle.end,
145
+ };
146
+ },
132
147
  tracingHeaders() {
133
148
  const headers = new Headers();
134
149
  if (trace.span_id !== undefined) {
@@ -151,7 +166,7 @@ export async function withTrace(options, fn, hooks) {
151
166
  const { name, kind = 'server', attributes, ...loggerOptions } = options;
152
167
  const logger = await createLogger(loggerOptions);
153
168
  try {
154
- return await logger.span(name, { kind, attributes }, fn);
169
+ return await logger.withSpan(name, { kind, attributes }, fn);
155
170
  }
156
171
  catch (err) {
157
172
  if (hooks?.onError) {
@@ -173,7 +188,8 @@ export const noopLogger = {
173
188
  metric: () => { },
174
189
  summary: () => { },
175
190
  child: () => noopLogger,
176
- span: (_name, _options, fn) => fn(noopLogger),
191
+ withSpan: (_name, _options, fn) => fn(noopLogger),
192
+ startSpan: () => ({ logger: noopLogger, end: () => { } }),
177
193
  tracingHeaders: () => new Headers(),
178
194
  };
179
195
  //# sourceMappingURL=logger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/producer/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAEhB,uBAAuB,GACxB,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,WAAW,EACX,OAAO,EAEP,eAAe,GAEhB,MAAM,WAAW,CAAA;AAmDlB,MAAM,kBAAkB,GAAG,UAAU,CAAA;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACA,CAAA;AAIV,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,QAAQ,CAAA;A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AqB,EAAE,EAAkC,EAAE,EAAE,CACxF,EAAE,CAAC,UAAU,CAAC;IAChB,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;IACxD,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,EAAE;CACpC,CAAA"}
@@ -1,3 +1,3 @@
1
- export { createClock, type Clock } from './clock';
2
- export { runSpan, toSpanException, type ChildTraceContext, type SpanOptions, type TraceContext, } from './span';
1
+ export { createClock, type Clock } from './clock.js';
2
+ export { runSpan, startSpan, toSpanException, type ChildTraceContext, type Exit, type SpanHandle, type SpanOptions, type TraceContext, } from './span.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/producer/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAA;AACjD,OAAO,EACL,OAAO,EACP,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/producer/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,WAAW,CAAA"}
@@ -1,3 +1,3 @@
1
- export { createClock } from './clock';
2
- export { runSpan, toSpanException, } from './span';
1
+ export { createClock } from './clock.js';
2
+ export { runSpan, startSpan, toSpanException, } from './span.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/producer/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,SAAS,CAAA;AACjD,OAAO,EACL,OAAO,EACP,eAAe,GAIhB,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/producer/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,YAAY,CAAA;AACpD,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,GAMhB,MAAM,WAAW,CAAA"}
@@ -1,5 +1,5 @@
1
- import { type AttributeValue, type SpanException, type SpanKind } from '../../protocol';
2
- import type { Clock } from './clock';
1
+ import { type AttributeValue, type SpanException, type SpanKind } from '../../protocol/index.js';
2
+ import type { Clock } from './clock.js';
3
3
  export interface SpanOptions {
4
4
  kind: SpanKind;
5
5
  attributes?: Record<string, AttributeValue>;
@@ -35,7 +35,41 @@ export interface TraceContext {
35
35
  export interface ChildTraceContext extends TraceContext {
36
36
  readonly span_id: string;
37
37
  }
38
- export interface RunSpanInput<T> {
38
+ /**
39
+ * Tagged outcome of a span's lifetime. Callers settle a span with one of these
40
+ * tags so success / failure / cancellation each have a first-class encoding —
41
+ * no overloading of return values vs thrown exceptions, no "the error path is
42
+ * implicit." Borrowed from Effect's `Exit` shape.
43
+ *
44
+ * - `ok` — work completed successfully; carries the result value.
45
+ * - `error` — work failed; carries the thrown value. `isExpectedError` decides
46
+ * whether the span records `status: error` or `status: ok` (expected user-facing
47
+ * failures like `SaptError` shouldn't pollute error dashboards).
48
+ * - `aborted` — work was cancelled (e.g. user clicked stop, client disconnected).
49
+ * Recorded as `status: ok` with a `span.aborted: true` attribute so dashboards
50
+ * can distinguish abandonment from completion without inflating error rates.
51
+ */
52
+ export type Exit<T> = {
53
+ tag: 'ok';
54
+ value: T;
55
+ } | {
56
+ tag: 'error';
57
+ error: unknown;
58
+ } | {
59
+ tag: 'aborted';
60
+ };
61
+ /** Handle for a span whose lifetime is driven by external callbacks. */
62
+ export interface SpanHandle {
63
+ /** Trace identifiers for the span. Use to build a child logger. */
64
+ readonly trace: ChildTraceContext;
65
+ /**
66
+ * Emit the span event. Idempotent — second and later calls are ignored, so
67
+ * racing callbacks (e.g. `onError` after `onAbort`) settle deterministically
68
+ * on first-write-wins.
69
+ */
70
+ end(exit: Exit<unknown>): void;
71
+ }
72
+ export interface StartSpanInput {
39
73
  parent: TraceContext;
40
74
  resource: {
41
75
  service: string;
@@ -45,13 +79,28 @@ export interface RunSpanInput<T> {
45
79
  options: SpanOptions;
46
80
  clock: Clock;
47
81
  isExpectedError?: (err: unknown) => boolean;
48
- fn: (child: ChildTraceContext) => Promise<T>;
82
+ /** Invoked with the unexpected error once `end({ tag: 'error', error })` runs. */
49
83
  onUnexpectedError?: (err: unknown, child: ChildTraceContext) => void;
50
84
  }
85
+ /**
86
+ * Open a span whose lifetime is settled later by `handle.end(exit)`. Use when
87
+ * the span's duration doesn't align with a function scope — for example a span
88
+ * driven by streaming callbacks (`onFinish` / `onError` / `onAbort`).
89
+ *
90
+ * For function-scoped work prefer `runSpan` (or `logger.withSpan`), which can't
91
+ * leak because the function boundary settles the span automatically.
92
+ */
93
+ export declare function startSpan(input: StartSpanInput): SpanHandle;
94
+ export interface RunSpanInput<T> extends StartSpanInput {
95
+ fn: (child: ChildTraceContext) => Promise<T>;
96
+ }
51
97
  /**
52
98
  * Run an async function inside a span. Emits a SpanEvent on completion (success or
53
99
  * failure). Errors matched by `isExpectedError` are recorded as `status: 'ok'` but
54
100
  * still re-thrown — they're expected user-facing failures, not span failures.
101
+ *
102
+ * Thin wrapper over `startSpan` for the common case where the span's lifetime
103
+ * aligns with a function call.
55
104
  */
56
105
  export declare function runSpan<T>(input: RunSpanInput<T>): Promise<T>;
57
106
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../../src/producer/tracing/span.ts"],"names":[],"mappings":"AAAA,OAAO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AAC,OAAO,CAAC,GAAG,IAAI,CAAA;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,YAAY,CAAA;IACpB,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,EAAE,KAAK,CAAA;IACZ,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;IAC3C,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;CACrE;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CA8D3D;AAED,MAAM,WAAW,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc;IACrD,EAAE,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAWnE;AAQD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAU3D"}
@@ -1,11 +1,14 @@
1
- import { generateSpanId, SPAN_EVENT_TYPE, } from '../../protocol';
1
+ import { generateSpanId, SPAN_EVENT_TYPE, } from '../../protocol/index.js';
2
2
  /**
3
- * Run an async function inside a span. Emits a SpanEvent on completion (success or
4
- * failure). Errors matched by `isExpectedError` are recorded as `status: 'ok'` but
5
- * still re-thrown they're expected user-facing failures, not span failures.
3
+ * Open a span whose lifetime is settled later by `handle.end(exit)`. Use when
4
+ * the span's duration doesn't align with a function scope for example a span
5
+ * driven by streaming callbacks (`onFinish` / `onError` / `onAbort`).
6
+ *
7
+ * For function-scoped work prefer `runSpan` (or `logger.withSpan`), which can't
8
+ * leak because the function boundary settles the span automatically.
6
9
  */
7
- export async function runSpan(input) {
8
- const { parent, resource, name, options, clock, isExpectedError, fn, onUnexpectedError } = input;
10
+ export function startSpan(input) {
11
+ const { parent, resource, name, options, clock, isExpectedError, onUnexpectedError } = input;
9
12
  const child = {
10
13
  trace_id: parent.trace_id,
11
14
  span_id: generateSpanId(),
@@ -18,26 +21,70 @@ export async function runSpan(input) {
18
21
  ...resource,
19
22
  name,
20
23
  kind: options.kind,
21
- attributes: options.attributes,
22
24
  };
25
+ let settled = false;
26
+ return {
27
+ trace: child,
28
+ end(exit) {
29
+ if (settled)
30
+ return;
31
+ settled = true;
32
+ const endTimeUnixNano = clock.nowUnixNano();
33
+ if (exit.tag === 'ok') {
34
+ emitSpan({
35
+ ...base,
36
+ attributes: options.attributes,
37
+ status: 'ok',
38
+ startTimeUnixNano,
39
+ endTimeUnixNano,
40
+ });
41
+ return;
42
+ }
43
+ if (exit.tag === 'aborted') {
44
+ emitSpan({
45
+ ...base,
46
+ attributes: { ...options.attributes, 'span.aborted': true },
47
+ status: 'ok',
48
+ startTimeUnixNano,
49
+ endTimeUnixNano,
50
+ });
51
+ return;
52
+ }
53
+ // tag === 'error'
54
+ const expected = isExpectedError?.(exit.error) === true;
55
+ const exception = expected ? undefined : toSpanException(exit.error);
56
+ emitSpan({
57
+ ...base,
58
+ attributes: options.attributes,
59
+ status: expected ? 'ok' : 'error',
60
+ statusMessage: exception?.message,
61
+ exception,
62
+ startTimeUnixNano,
63
+ endTimeUnixNano,
64
+ });
65
+ if (!expected)
66
+ onUnexpectedError?.(exit.error, child);
67
+ },
68
+ };
69
+ }
70
+ /**
71
+ * Run an async function inside a span. Emits a SpanEvent on completion (success or
72
+ * failure). Errors matched by `isExpectedError` are recorded as `status: 'ok'` but
73
+ * still re-thrown — they're expected user-facing failures, not span failures.
74
+ *
75
+ * Thin wrapper over `startSpan` for the common case where the span's lifetime
76
+ * aligns with a function call.
77
+ */
78
+ export async function runSpan(input) {
79
+ const { fn, ...rest } = input;
80
+ const handle = startSpan(rest);
23
81
  try {
24
- const result = await fn(child);
25
- emitSpan({ ...base, status: 'ok', startTimeUnixNano, endTimeUnixNano: clock.nowUnixNano() });
82
+ const result = await fn(handle.trace);
83
+ handle.end({ tag: 'ok', value: result });
26
84
  return result;
27
85
  }
28
86
  catch (err) {
29
- const expected = isExpectedError?.(err) === true;
30
- const exception = expected ? undefined : toSpanException(err);
31
- emitSpan({
32
- ...base,
33
- status: expected ? 'ok' : 'error',
34
- statusMessage: exception?.message,
35
- exception,
36
- startTimeUnixNano,
37
- endTimeUnixNano: clock.nowUnixNano(),
38
- });
39
- if (!expected)
40
- onUnexpectedError?.(err, child);
87
+ handle.end({ tag: 'error', error: err });
41
88
  throw err;
42
89
  }
43
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"span.js","sourceRoot":"","sources":["../../../src/producer/tracing/span.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,eAAe,GAIhB,MAAM,gBAAgB,CAAA;AAoDvB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB;IACrD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAA;IAChG,MAAM,KAAK,GAAsB;QAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,OAAO,EAAE,cAAc,EAAE;QACzB,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,cAAc;QACvD,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAA;IAED,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA;IAC7C,MAAM,IAAI,GAAG;QACX,GAAG,KAAK;QACR,GAAG,QAAQ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,QAAQ,EAAE,CAAC;YACzF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;QACtD,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,OAAO,YAAY,CAAA;QACpD,OAAO,kBAAkB,CAAA;IAC3B,CAAC;AACH,CAAC"}
@@ -39,5 +39,5 @@ export type TailHandler = (events: TraceItem[], env: unknown, ctx: ExecutionCont
39
39
  * ```
40
40
  */
41
41
  export declare function createTailHandler(config: AxiomConfig): TailHandler;
42
- export { sendSpansToAxiom } from './spans';
42
+ export { sendSpansToAxiom } from './spans.js';
43
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tail/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,SAAS,EAAE,EACnB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAAC,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA6FlE;AA8FD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tail/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,CACxB,MAAM,EAAE,SAAS,EAAE,EACnB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,gBAAgB,KAClB,OAAO,CAAC,IAAI,CAAC,CAAA;AAElB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA6FlE;AA8FD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
@@ -1,5 +1,5 @@
1
- import { isSpanEvent, SUMMARY_PROPERTIES_TYPE } from '../protocol';
2
- import { sendSpansToAxiom } from './spans';
1
+ import { isSpanEvent, SUMMARY_PROPERTIES_TYPE } from '../protocol/index.js';
2
+ import { sendSpansToAxiom } from './spans.js';
3
3
  /**
4
4
  * Build a Cloudflare Workers `tail()` handler that forwards logs, metrics,
5
5
  * errors, and spans from any number of producing workers to Axiom.
@@ -151,5 +151,5 @@ async function sendToAxiom(params) {
151
151
  throw new Error(`Failed to send logs to Axiom: ${response.status} ${response.statusText} — ${text}`);
152
152
  }
153
153
  }
154
- export { sendSpansToAxiom } from './spans';
154
+ export { sendSpansToAxiom } from './spans.js';
155
155
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AA0B1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,MAAM,CAA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AAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,UAAU,EAAE;SACtC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;KAC7B,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAA;QAC3D,MAAM,IAAI,KAAK,CACb,iCAAiC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,IAAI,EAAE,CACpF,CAAA;IACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
@@ -7,7 +7,7 @@
7
7
  * router that forwards only `sampled === true` spans. Logs/metrics/errors are
8
8
  * forwarded unconditionally by the caller — sampling gates traces, not log visibility.
9
9
  */
10
- import type { SpanEvent } from '../protocol';
10
+ import type { SpanEvent } from '../protocol/index.js';
11
11
  export interface SendSpansInput {
12
12
  spans: SpanEvent[];
13
13
  axiomToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../src/tail/spans.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAU5C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3E"}
1
+ {"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../src/tail/spans.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAUrD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workers-axiom",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Structured logging, tracing, and metrics for Cloudflare Workers, with an Axiom tail-worker sink.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,13 +29,12 @@
29
29
  "dist",
30
30
  "src"
31
31
  ],
32
- "scripts": {
33
- "build": "rm -rf dist && tsc -p tsconfig.build.json",
34
- "typecheck": "tsc --noEmit",
35
- "prepublishOnly": "pnpm run build"
36
- },
37
32
  "devDependencies": {
38
33
  "@cloudflare/workers-types": "^4.20250101.0",
39
34
  "typescript": "^5.6.0"
35
+ },
36
+ "scripts": {
37
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
38
+ "typecheck": "tsc --noEmit"
40
39
  }
41
- }
40
+ }
@@ -7,10 +7,11 @@ export {
7
7
  type LogContext,
8
8
  type Logger,
9
9
  type LoggerOptions,
10
+ type LoggerSpanHandle,
10
11
  type WithTraceOptions,
11
- } from './logger'
12
+ } from './logger.js'
12
13
 
13
- export type { SpanOptions, TraceContext } from './tracing'
14
+ export type { Exit, SpanHandle, SpanOptions, TraceContext } from './tracing/index.js'
14
15
 
15
16
  // Re-export wire-format types that consumers commonly need when extending
16
17
  // the producer (custom attributes, propagation helpers in middleware, etc.).
@@ -25,4 +26,4 @@ export {
25
26
  type SpanKind,
26
27
  type SpanStatus,
27
28
  type TraceParent,
28
- } from '../protocol'
29
+ } from '../protocol/index.js'
@@ -5,15 +5,18 @@ import {
5
5
  parseTraceparent,
6
6
  type SpanKind,
7
7
  SUMMARY_PROPERTIES_TYPE,
8
- } from '../protocol'
8
+ } from '../protocol/index.js'
9
9
  import {
10
10
  type Clock,
11
11
  createClock,
12
+ type Exit,
12
13
  runSpan,
14
+ type SpanHandle,
13
15
  type SpanOptions,
16
+ startSpan,
14
17
  toSpanException,
15
18
  type TraceContext,
16
- } from './tracing'
19
+ } from './tracing/index.js'
17
20
 
18
21
  /**
19
22
  * Bag of correlation fields (requestId, actorId, etc.). Has no semantic meaning
@@ -55,7 +58,21 @@ export interface Logger {
55
58
  * creation) are recorded as `status: 'ok'` — they're expected user-facing
56
59
  * failures, not span failures.
57
60
  */
58
- span<T>(name: string, options: SpanOptions, fn: (logger: Logger) => Promise<T>): Promise<T>
61
+ withSpan<T>(name: string, options: SpanOptions, fn: (logger: Logger) => Promise<T>): Promise<T>
62
+ /**
63
+ * Open a span whose lifetime is settled later. Use when the span's duration
64
+ * doesn't align with a function scope (typically driven by external
65
+ * callbacks like a streaming API's `onFinish`/`onError`/`onAbort`).
66
+ *
67
+ * Returns a handle bundling a `Logger` already bound to the new span (so
68
+ * logs/metrics emitted via it correlate automatically) and an `end(exit)`
69
+ * method that settles the span with an `Exit` outcome. `end` is idempotent —
70
+ * first call wins, later calls are ignored.
71
+ *
72
+ * Prefer `withSpan` when the span's lifetime aligns with a function — that
73
+ * form can't leak.
74
+ */
75
+ startSpan(name: string, options: SpanOptions): LoggerSpanHandle
59
76
  /**
60
77
  * Returns headers to propagate the current trace context on outbound calls.
61
78
  * Always include the result on outbound `fetch` calls (including service
@@ -64,6 +81,14 @@ export interface Logger {
64
81
  tracingHeaders(): Headers
65
82
  }
66
83
 
84
+ /** Handle returned by `Logger.startSpan` — span-bound logger plus `end(exit)`. */
85
+ export interface LoggerSpanHandle {
86
+ /** Child logger bound to the new span; pass into work that should correlate. */
87
+ readonly logger: Logger
88
+ /** Settle the span. Idempotent: first call wins. */
89
+ end(exit: Exit<unknown>): void
90
+ }
91
+
67
92
  const BASE_LOG_LEVEL_KEY = 'logLevel'
68
93
 
69
94
  export const LogLevel = {
@@ -261,7 +286,7 @@ function _createLogger(options: LoggerOptions, clock: Clock, trace: TraceContext
261
286
  )
262
287
  },
263
288
 
264
- async span<T>(
289
+ async withSpan<T>(
265
290
  name: string,
266
291
  spanOptions: SpanOptions,
267
292
  fn: (logger: Logger) => Promise<T>
@@ -279,6 +304,23 @@ function _createLogger(options: LoggerOptions, clock: Clock, trace: TraceContext
279
304
  })
280
305
  },
281
306
 
307
+ startSpan(name: string, spanOptions: SpanOptions): LoggerSpanHandle {
308
+ const handle = startSpan({
309
+ parent: trace,
310
+ resource: { service, environment },
311
+ name,
312
+ options: spanOptions,
313
+ clock,
314
+ isExpectedError,
315
+ onUnexpectedError: (err, childCtx) =>
316
+ _createLogger(options, clock, childCtx).error(err, `span "${name}" failed`),
317
+ })
318
+ return {
319
+ logger: _createLogger(options, clock, handle.trace),
320
+ end: handle.end,
321
+ }
322
+ },
323
+
282
324
  tracingHeaders(): Headers {
283
325
  const headers = new Headers()
284
326
  if (trace.span_id !== undefined) {
@@ -315,7 +357,7 @@ export async function withTrace<T>(
315
357
  const { name, kind = 'server', attributes, ...loggerOptions } = options
316
358
  const logger = await createLogger(loggerOptions)
317
359
  try {
318
- return await logger.span(name, { kind, attributes }, fn)
360
+ return await logger.withSpan(name, { kind, attributes }, fn)
319
361
  } catch (err) {
320
362
  if (hooks?.onError) {
321
363
  return await hooks.onError(err, logger)
@@ -337,7 +379,8 @@ export const noopLogger: Logger = {
337
379
  metric: () => {},
338
380
  summary: () => {},
339
381
  child: () => noopLogger,
340
- span: <T>(_name: string, _options: SpanOptions, fn: (logger: Logger) => Promise<T>) =>
382
+ withSpan: <T>(_name: string, _options: SpanOptions, fn: (logger: Logger) => Promise<T>) =>
341
383
  fn(noopLogger),
384
+ startSpan: () => ({ logger: noopLogger, end: () => {} }),
342
385
  tracingHeaders: () => new Headers(),
343
386
  }
@@ -1,8 +1,11 @@
1
- export { createClock, type Clock } from './clock'
1
+ export { createClock, type Clock } from './clock.js'
2
2
  export {
3
3
  runSpan,
4
+ startSpan,
4
5
  toSpanException,
5
6
  type ChildTraceContext,
7
+ type Exit,
8
+ type SpanHandle,
6
9
  type SpanOptions,
7
10
  type TraceContext,
8
- } from './span'
11
+ } from './span.js'
@@ -5,8 +5,8 @@ import {
5
5
  type SpanEvent,
6
6
  type SpanException,
7
7
  type SpanKind,
8
- } from '../../protocol'
9
- import type { Clock } from './clock'
8
+ } from '../../protocol/index.js'
9
+ import type { Clock } from './clock.js'
10
10
 
11
11
  export interface SpanOptions {
12
12
  kind: SpanKind
@@ -46,24 +46,58 @@ export interface ChildTraceContext extends TraceContext {
46
46
  readonly span_id: string
47
47
  }
48
48
 
49
- export interface RunSpanInput<T> {
49
+ /**
50
+ * Tagged outcome of a span's lifetime. Callers settle a span with one of these
51
+ * tags so success / failure / cancellation each have a first-class encoding —
52
+ * no overloading of return values vs thrown exceptions, no "the error path is
53
+ * implicit." Borrowed from Effect's `Exit` shape.
54
+ *
55
+ * - `ok` — work completed successfully; carries the result value.
56
+ * - `error` — work failed; carries the thrown value. `isExpectedError` decides
57
+ * whether the span records `status: error` or `status: ok` (expected user-facing
58
+ * failures like `SaptError` shouldn't pollute error dashboards).
59
+ * - `aborted` — work was cancelled (e.g. user clicked stop, client disconnected).
60
+ * Recorded as `status: ok` with a `span.aborted: true` attribute so dashboards
61
+ * can distinguish abandonment from completion without inflating error rates.
62
+ */
63
+ export type Exit<T> =
64
+ | { tag: 'ok'; value: T }
65
+ | { tag: 'error'; error: unknown }
66
+ | { tag: 'aborted' }
67
+
68
+ /** Handle for a span whose lifetime is driven by external callbacks. */
69
+ export interface SpanHandle {
70
+ /** Trace identifiers for the span. Use to build a child logger. */
71
+ readonly trace: ChildTraceContext
72
+ /**
73
+ * Emit the span event. Idempotent — second and later calls are ignored, so
74
+ * racing callbacks (e.g. `onError` after `onAbort`) settle deterministically
75
+ * on first-write-wins.
76
+ */
77
+ end(exit: Exit<unknown>): void
78
+ }
79
+
80
+ export interface StartSpanInput {
50
81
  parent: TraceContext
51
82
  resource: { service: string; environment: string | undefined }
52
83
  name: string
53
84
  options: SpanOptions
54
85
  clock: Clock
55
86
  isExpectedError?: (err: unknown) => boolean
56
- fn: (child: ChildTraceContext) => Promise<T>
87
+ /** Invoked with the unexpected error once `end({ tag: 'error', error })` runs. */
57
88
  onUnexpectedError?: (err: unknown, child: ChildTraceContext) => void
58
89
  }
59
90
 
60
91
  /**
61
- * Run an async function inside a span. Emits a SpanEvent on completion (success or
62
- * failure). Errors matched by `isExpectedError` are recorded as `status: 'ok'` but
63
- * still re-thrown they're expected user-facing failures, not span failures.
92
+ * Open a span whose lifetime is settled later by `handle.end(exit)`. Use when
93
+ * the span's duration doesn't align with a function scope for example a span
94
+ * driven by streaming callbacks (`onFinish` / `onError` / `onAbort`).
95
+ *
96
+ * For function-scoped work prefer `runSpan` (or `logger.withSpan`), which can't
97
+ * leak because the function boundary settles the span automatically.
64
98
  */
65
- export async function runSpan<T>(input: RunSpanInput<T>): Promise<T> {
66
- const { parent, resource, name, options, clock, isExpectedError, fn, onUnexpectedError } = input
99
+ export function startSpan(input: StartSpanInput): SpanHandle {
100
+ const { parent, resource, name, options, clock, isExpectedError, onUnexpectedError } = input
67
101
  const child: ChildTraceContext = {
68
102
  trace_id: parent.trace_id,
69
103
  span_id: generateSpanId(),
@@ -77,25 +111,76 @@ export async function runSpan<T>(input: RunSpanInput<T>): Promise<T> {
77
111
  ...resource,
78
112
  name,
79
113
  kind: options.kind,
80
- attributes: options.attributes,
81
114
  }
82
115
 
116
+ let settled = false
117
+ return {
118
+ trace: child,
119
+ end(exit: Exit<unknown>): void {
120
+ if (settled) return
121
+ settled = true
122
+ const endTimeUnixNano = clock.nowUnixNano()
123
+
124
+ if (exit.tag === 'ok') {
125
+ emitSpan({
126
+ ...base,
127
+ attributes: options.attributes,
128
+ status: 'ok',
129
+ startTimeUnixNano,
130
+ endTimeUnixNano,
131
+ })
132
+ return
133
+ }
134
+
135
+ if (exit.tag === 'aborted') {
136
+ emitSpan({
137
+ ...base,
138
+ attributes: { ...options.attributes, 'span.aborted': true },
139
+ status: 'ok',
140
+ startTimeUnixNano,
141
+ endTimeUnixNano,
142
+ })
143
+ return
144
+ }
145
+
146
+ // tag === 'error'
147
+ const expected = isExpectedError?.(exit.error) === true
148
+ const exception = expected ? undefined : toSpanException(exit.error)
149
+ emitSpan({
150
+ ...base,
151
+ attributes: options.attributes,
152
+ status: expected ? 'ok' : 'error',
153
+ statusMessage: exception?.message,
154
+ exception,
155
+ startTimeUnixNano,
156
+ endTimeUnixNano,
157
+ })
158
+ if (!expected) onUnexpectedError?.(exit.error, child)
159
+ },
160
+ }
161
+ }
162
+
163
+ export interface RunSpanInput<T> extends StartSpanInput {
164
+ fn: (child: ChildTraceContext) => Promise<T>
165
+ }
166
+
167
+ /**
168
+ * Run an async function inside a span. Emits a SpanEvent on completion (success or
169
+ * failure). Errors matched by `isExpectedError` are recorded as `status: 'ok'` but
170
+ * still re-thrown — they're expected user-facing failures, not span failures.
171
+ *
172
+ * Thin wrapper over `startSpan` for the common case where the span's lifetime
173
+ * aligns with a function call.
174
+ */
175
+ export async function runSpan<T>(input: RunSpanInput<T>): Promise<T> {
176
+ const { fn, ...rest } = input
177
+ const handle = startSpan(rest)
83
178
  try {
84
- const result = await fn(child)
85
- emitSpan({ ...base, status: 'ok', startTimeUnixNano, endTimeUnixNano: clock.nowUnixNano() })
179
+ const result = await fn(handle.trace)
180
+ handle.end({ tag: 'ok', value: result })
86
181
  return result
87
182
  } catch (err) {
88
- const expected = isExpectedError?.(err) === true
89
- const exception = expected ? undefined : toSpanException(err)
90
- emitSpan({
91
- ...base,
92
- status: expected ? 'ok' : 'error',
93
- statusMessage: exception?.message,
94
- exception,
95
- startTimeUnixNano,
96
- endTimeUnixNano: clock.nowUnixNano(),
97
- })
98
- if (!expected) onUnexpectedError?.(err, child)
183
+ handle.end({ tag: 'error', error: err })
99
184
  throw err
100
185
  }
101
186
  }
package/src/tail/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { isSpanEvent, type SpanEvent, SUMMARY_PROPERTIES_TYPE } from '../protocol'
2
- import { sendSpansToAxiom } from './spans'
1
+ import { isSpanEvent, type SpanEvent, SUMMARY_PROPERTIES_TYPE } from '../protocol/index.js'
2
+ import { sendSpansToAxiom } from './spans.js'
3
3
 
4
4
  export interface AxiomConfig {
5
5
  /** Axiom API token. */
@@ -234,4 +234,4 @@ async function sendToAxiom(params: {
234
234
  }
235
235
  }
236
236
 
237
- export { sendSpansToAxiom } from './spans'
237
+ export { sendSpansToAxiom } from './spans.js'
package/src/tail/spans.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * router that forwards only `sampled === true` spans. Logs/metrics/errors are
8
8
  * forwarded unconditionally by the caller — sampling gates traces, not log visibility.
9
9
  */
10
- import type { SpanEvent } from '../protocol'
10
+ import type { SpanEvent } from '../protocol/index.js'
11
11
 
12
12
  const SPAN_KIND_TO_OTLP: Record<SpanEvent['kind'], number> = {
13
13
  internal: 1,