@nxgt/telemetry 0.1.0 → 0.2.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/dist/index.js.map CHANGED
@@ -1,13 +1,25 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/attributes/attributes.ts", "../src/model/signal.ts", "../src/trace/ids.ts", "../src/trace/sampler.ts"],
3
+ "sources": ["../src/attributes/attributes.ts", "../src/context/current.ts", "../src/export/pipeline.ts", "../src/trace/ids.ts", "../src/trace/sampler.ts", "../src/telemetry/telemetry.ts", "../src/export/console.ts", "../src/export/file.ts", "../src/export/rotation.ts", "../src/export/json-lines.ts", "../src/logger/event.ts", "../src/model/error.ts", "../src/model/signal.ts", "../src/logger/logger.ts", "../src/span/scope.ts", "../src/span/span.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * An attribute is a scalar, or a list of scalars. That is what a backend can\n * index, filter and group by, and it is what OTLP accepts. Anything with\n * structure is an event type, not an attribute.\n *\n * The coercion below never refuses a value: a log call must not fail, so a\n * shape that does not belong here is rendered rather than rejected.\n */\n\nexport type AttributeScalar = string | number | boolean | null;\n\nexport type AttributeValue = AttributeScalar | readonly AttributeScalar[];\n\nexport type Attributes = Readonly<Record<string, AttributeValue>>;\n\n/** Shared, frozen, and the one to return when there is nothing to say. */\nexport const EMPTY_ATTRIBUTES: Attributes = Object.freeze({});\n\n/**\n * Whatever a caller passed, as something that can be indexed.\n *\n * - `undefined` and a symbol render as `null`;\n * - a non-finite number renders as its text, because `NaN` is not JSON;\n * - a `bigint` renders as its text, for the same reason;\n * - a `Date` renders as an ISO-8601 instant;\n * - an array renders element by element, and a nested array is flattened into\n * text rather than dropped;\n * - anything else is JSON if it will serialise, and `String(value)` if it will\n * not — a circular object still says something.\n */\nexport function coerceAttribute(value: unknown): AttributeValue {\n\tif (value === null || value === undefined) return null;\n\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\tcase 'boolean':\n\t\t\treturn value;\n\t\tcase 'number':\n\t\t\treturn Number.isFinite(value) ? value : String(value);\n\t\tcase 'bigint':\n\t\t\treturn String(value);\n\t\tcase 'symbol':\n\t\tcase 'function':\n\t\t\treturn null;\n\t}\n\n\tif (value instanceof Date) {\n\t\tconst at = value.getTime();\n\t\treturn Number.isNaN(at) ? String(value) : value.toISOString();\n\t}\n\n\tif (Array.isArray(value)) return value.map(coerceScalar);\n\n\treturn render(value);\n}\n\n/**\n * A record of anything, as attributes. Keys whose value is `undefined` are\n * dropped — `{ orderId, code }` with no `code` should not log `code: null` —\n * while an explicit `null` is kept, because somebody wrote it.\n */\nexport function attributesOf(\n\tinput: Readonly<Record<string, unknown>> | undefined,\n): Attributes {\n\tif (input === undefined) return EMPTY_ATTRIBUTES;\n\n\tconst attributes: Record<string, AttributeValue> = {};\n\tlet any = false;\n\n\tfor (const key of Object.keys(input)) {\n\t\tconst value = input[key];\n\t\tif (value === undefined) continue;\n\t\tattributes[key] = coerceAttribute(value);\n\t\tany = true;\n\t}\n\n\treturn any ? attributes : EMPTY_ATTRIBUTES;\n}\n\n/** Both, with the right-hand side winning. Neither argument is modified. */\nexport function mergeAttributes(\n\tleft: Attributes,\n\tright: Attributes,\n): Attributes {\n\tif (left === right) return left;\n\tif (isEmpty(left)) return right;\n\tif (isEmpty(right)) return left;\n\treturn { ...left, ...right };\n}\n\nexport function isEmptyAttributes(attributes: Attributes): boolean {\n\treturn isEmpty(attributes);\n}\n\nfunction isEmpty(attributes: Attributes): boolean {\n\tfor (const _ in attributes) return false;\n\treturn true;\n}\n\nfunction coerceScalar(value: unknown): AttributeScalar {\n\tconst coerced = coerceAttribute(value);\n\treturn Array.isArray(coerced) ? render(value) : (coerced as AttributeScalar);\n}\n\nfunction render(value: unknown): string {\n\ttry {\n\t\tconst json = JSON.stringify(value);\n\t\tif (json !== undefined) return json;\n\t} catch {\n\t\t// Circular, or a `toJSON` that threw. `String` still says something.\n\t}\n\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\treturn '[unrenderable]';\n\t}\n}\n",
6
- "import type { Attributes } from '../attributes/attributes';\nimport type { SpanContext, SpanId } from '../trace/ids';\n\n/**\n * The signal model. It is shared with `stx-telemetry`, the Kotlin counterpart:\n * the same four severities, the same span kinds and statuses, the same\n * discriminator. Changing anything here means the two estates have diverged.\n *\n * Instants are epoch **milliseconds**, which is the precision a JavaScript wall\n * clock has. OTLP wants nanoseconds, and the exporter multiplies.\n */\n\n/**\n * Four levels, and there is no `trace`: detail below `debug` is an attribute on\n * a span, where it is attached to the work it describes rather than to a line\n * somebody has to correlate by hand.\n */\nexport type Severity = 'debug' | 'info' | 'warn' | 'error';\n\n/** OTLP's numbers, which is what makes a backend order them correctly. */\nexport const SEVERITY_NUMBER: Readonly<Record<Severity, number>> =\n\tObject.freeze({\n\t\tdebug: 5,\n\t\tinfo: 9,\n\t\twarn: 13,\n\t\terror: 17,\n\t});\n\n/** Ascending, so a floor can be compared by index as well as by number. */\nexport const SEVERITIES: readonly Severity[] = Object.freeze([\n\t'debug',\n\t'info',\n\t'warn',\n\t'error',\n] as const);\n\n/** Whether `severity` clears the `minimum` floor. */\nexport function meetsSeverity(severity: Severity, minimum: Severity): boolean {\n\treturn SEVERITY_NUMBER[severity] >= SEVERITY_NUMBER[minimum];\n}\n\nexport type SpanKind =\n\t| 'internal'\n\t| 'server'\n\t| 'client'\n\t| 'producer'\n\t| 'consumer';\n\nexport const SPAN_KIND_NUMBER: Readonly<Record<SpanKind, number>> =\n\tObject.freeze({\n\t\tinternal: 1,\n\t\tserver: 2,\n\t\tclient: 3,\n\t\tproducer: 4,\n\t\tconsumer: 5,\n\t});\n\n/**\n * `cancelled` is distinct from `error` on purpose: a shutdown and a timeout are\n * not failures, and a dashboard that counts them as such is a dashboard nobody\n * trusts.\n */\nexport type SpanStatus = 'ok' | 'error' | 'cancelled';\n\n/** What every signal from one telemetry is about. */\nexport interface Resource {\n\treadonly service: string;\n\treadonly version?: string;\n\treadonly environment?: string;\n\treadonly attributes: Attributes;\n}\n\n/** A failure, flattened: the stack is text, because it crosses the wire. */\nexport interface ErrorInfo {\n\treadonly type: string;\n\treadonly message?: string;\n\treadonly stackTrace?: string;\n}\n\nexport interface LogRecord {\n\treadonly type: 'log';\n\t/** Epoch milliseconds. */\n\treadonly at: number;\n\treadonly severity: Severity;\n\t/** The event's name, or the message when there is no type for it yet. */\n\treadonly name: string;\n\t/** The logger's name. It becomes the OTLP instrumentation scope. */\n\treadonly source: string;\n\treadonly attributes: Attributes;\n\t/** Absent for a log written outside any span. */\n\treadonly span?: SpanContext;\n\treadonly error?: ErrorInfo;\n}\n\nexport interface SpanEvent {\n\treadonly name: string;\n\t/** Epoch milliseconds. */\n\treadonly at: number;\n\treadonly attributes: Attributes;\n}\n\nexport interface SpanRecord {\n\treadonly type: 'span';\n\treadonly name: string;\n\treadonly context: SpanContext;\n\t/** Absent for a root span. */\n\treadonly parent?: SpanId;\n\treadonly kind: SpanKind;\n\t/** Epoch milliseconds. */\n\treadonly startedAt: number;\n\t/** Epoch milliseconds. */\n\treadonly endedAt: number;\n\treadonly status: SpanStatus;\n\treadonly attributes: Attributes;\n\treadonly events: readonly SpanEvent[];\n\treadonly error?: ErrorInfo;\n}\n\n/**\n * The discriminator is the field `type`, with the values `\"log\"` and `\"span\"`.\n * It is not a class name, so that metrics can arrive as a third variant without\n * anything in the model or in the `Exporter` contract changing.\n */\nexport type Signal = LogRecord | SpanRecord;\n\n/** When a signal happened, whichever kind it is. */\nexport function signalAt(signal: Signal): number {\n\treturn signal.type === 'log' ? signal.at : signal.startedAt;\n}\n\n/** The span a signal belongs to, whichever kind it is. */\nexport function signalSpan(signal: Signal): SpanContext | undefined {\n\treturn signal.type === 'log' ? signal.span : signal.context;\n}\n",
5
+ "/**\n * An attribute is a scalar, or a list of scalars. That is what a backend can\n * index, filter and group by, and it is what OTLP accepts. Anything with\n * structure is an event type, not an attribute.\n *\n * The coercion below never refuses a value: a log call must not fail, so a\n * shape that does not belong here is rendered rather than rejected.\n */\n\nexport type AttributeScalar = string | number | boolean | null;\n\nexport type AttributeValue = AttributeScalar | readonly AttributeScalar[];\n\nexport type Attributes = Readonly<Record<string, AttributeValue>>;\n\n/** Shared, frozen, and the one to return when there is nothing to say. */\nexport const EMPTY_ATTRIBUTES: Attributes = Object.freeze({});\n\n/**\n * What a value reads as when reading it threw. A getter that throws, a revoked\n * Proxy and a `toString` that raises all arrive here — from application code,\n * in a `catch`, which is exactly where a log must not become the second\n * failure.\n */\nexport const UNREADABLE = '[unreadable]';\n\n/**\n * Whatever a caller passed, as something that can be indexed.\n *\n * - `undefined` and a symbol render as `null`;\n * - a non-finite number renders as its text, because `NaN` is not JSON;\n * - a `bigint` renders as its text, for the same reason;\n * - a `Date` renders as an ISO-8601 instant;\n * - an array renders element by element, and a nested array is flattened into\n * text rather than dropped;\n * - anything else is JSON if it will serialise, and `String(value)` if it will\n * not — a circular object still says something.\n */\nexport function coerceAttribute(value: unknown): AttributeValue {\n\ttry {\n\t\treturn coerce(value);\n\t} catch {\n\t\t// Reading the value ran application code, and it threw. Writing a\n\t\t// signal is a total function: it says so and carries on.\n\t\treturn UNREADABLE;\n\t}\n}\n\nfunction coerce(value: unknown): AttributeValue {\n\tif (value === null || value === undefined) return null;\n\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\tcase 'boolean':\n\t\t\treturn value;\n\t\tcase 'number':\n\t\t\treturn Number.isFinite(value) ? value : String(value);\n\t\tcase 'bigint':\n\t\t\treturn String(value);\n\t\tcase 'symbol':\n\t\tcase 'function':\n\t\t\treturn null;\n\t}\n\n\tif (value instanceof Date) {\n\t\tconst at = value.getTime();\n\t\treturn Number.isNaN(at) ? String(value) : value.toISOString();\n\t}\n\n\tif (Array.isArray(value)) return value.map(coerceScalar);\n\n\treturn render(value);\n}\n\n/**\n * A record of anything, as attributes. Keys whose value is `undefined` are\n * dropped — `{ orderId, code }` with no `code` should not log `code: null` —\n * while an explicit `null` is kept, because somebody wrote it.\n */\nexport function attributesOf(\n\tinput: Readonly<Record<string, unknown>> | undefined,\n): Attributes {\n\tif (input === undefined || input === null) return EMPTY_ATTRIBUTES;\n\n\t// `Object.keys` runs an `ownKeys` trap, and reading a key runs a getter.\n\t// Both are application code on the path that writes a signal.\n\tlet keys: string[];\n\ttry {\n\t\tkeys = Object.keys(input);\n\t} catch {\n\t\treturn EMPTY_ATTRIBUTES;\n\t}\n\n\tconst attributes: Record<string, AttributeValue> = {};\n\tlet any = false;\n\n\tfor (const key of keys) {\n\t\tlet value: unknown;\n\t\ttry {\n\t\t\tvalue = input[key];\n\t\t} catch {\n\t\t\tattributes[key] = UNREADABLE;\n\t\t\tany = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (value === undefined) continue;\n\t\tattributes[key] = coerceAttribute(value);\n\t\tany = true;\n\t}\n\n\treturn any ? attributes : EMPTY_ATTRIBUTES;\n}\n\n/** Both, with the right-hand side winning. Neither argument is modified. */\nexport function mergeAttributes(\n\tleft: Attributes,\n\tright: Attributes,\n): Attributes {\n\tif (left === right) return left;\n\tif (isEmpty(left)) return right;\n\tif (isEmpty(right)) return left;\n\treturn { ...left, ...right };\n}\n\nexport function isEmptyAttributes(attributes: Attributes): boolean {\n\treturn isEmpty(attributes);\n}\n\nfunction isEmpty(attributes: Attributes): boolean {\n\tfor (const _ in attributes) return false;\n\treturn true;\n}\n\nfunction coerceScalar(value: unknown): AttributeScalar {\n\tconst coerced = coerceAttribute(value);\n\treturn Array.isArray(coerced) ? render(value) : (coerced as AttributeScalar);\n}\n\nfunction render(value: unknown): string {\n\ttry {\n\t\tconst json = JSON.stringify(value);\n\t\tif (json !== undefined) return json;\n\t} catch {\n\t\t// Circular, or a `toJSON` that threw. `String` still says something.\n\t}\n\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\treturn UNREADABLE;\n\t}\n}\n",
6
+ "import * as asyncHooks from 'node:async_hooks';\nimport {\n\ttype Attributes,\n\tattributesOf,\n\tEMPTY_ATTRIBUTES,\n\tmergeAttributes,\n} from '../attributes/attributes';\nimport { installedTelemetry, type Telemetry } from '../telemetry/telemetry';\nimport { renderTraceparent, type SpanContext } from '../trace/ids';\n\n/**\n * What travels with the work: which telemetry is writing, which span is open,\n * and the attributes everything inside inherits.\n */\nexport interface TelemetryContext {\n\treadonly telemetry: Telemetry;\n\t/** Absent between `withTelemetry` and the first `span`. */\n\treadonly span?: SpanContext;\n\treadonly attributes: Attributes;\n}\n\n/**\n * The current context lives in an `AsyncLocalStorage`, and that is the whole\n * design.\n *\n * It propagates through every `await`, every timer and every promise chain:\n * into everything started inside a span, out of nothing, and correct after any\n * number of suspensions. A module-level `let current` would look right in\n * development and start attributing one request's spans to another under\n * concurrency — a bug with no stack trace and no failing test, in the tool\n * meant to make such bugs visible.\n *\n * It is also readable **synchronously**, which is what lets `log.info()` stay a\n * plain function: a log written from a constructor, from a `catch` in ordinary\n * code or from a callback still has to come out, and an async logger cannot be\n * called from any of them.\n */\nconst storage = createStorage();\n\nexport function currentContext(): TelemetryContext | undefined {\n\treturn storage.getStore();\n}\n\n/** Runs `fn` with `context` current, and restores whatever was there after. */\nexport function runWithContext<T>(context: TelemetryContext, fn: () => T): T {\n\treturn storage.run(context, fn);\n}\n\n/**\n * The telemetry a logger or a span should write to: the one **in scope** first,\n * the **installed** one second.\n *\n * That order is what lets two suites in one process each collect their own\n * signals, and it is why `withTelemetry` exists.\n */\nexport function resolveTelemetry(): Telemetry | undefined {\n\treturn currentContext()?.telemetry ?? installedTelemetry();\n}\n\n/** Runs `fn` with `telemetry` in scope, in place of the installed one. */\nexport function withTelemetry<T>(telemetry: Telemetry, fn: () => T): T {\n\tconst context = currentContext();\n\treturn runWithContext(\n\t\t{\n\t\t\ttelemetry,\n\t\t\t...(context?.span === undefined ? {} : { span: context.span }),\n\t\t\tattributes: context?.attributes ?? EMPTY_ATTRIBUTES,\n\t\t},\n\t\tfn,\n\t);\n}\n\n/**\n * Runs `fn` with these attributes inherited by every log and span inside it.\n *\n * With no context open but a telemetry installed — the top level of an\n * application, before any span — it opens one, so the attributes reach the logs\n * written there. With nothing installed either it runs `fn` unchanged:\n * attaching attributes to nothing is not an error, and a library that does it\n * must work in an application that has never heard of this one.\n */\nexport function withAttributes<T>(\n\tattributes: Readonly<Record<string, unknown>>,\n\tfn: () => T,\n): T {\n\tconst given = attributesOf(attributes);\n\tconst context = currentContext();\n\n\tif (context === undefined) {\n\t\tconst telemetry = installedTelemetry();\n\t\tif (telemetry === undefined) return fn();\n\t\treturn runWithContext({ telemetry, attributes: given }, fn);\n\t}\n\n\treturn runWithContext(\n\t\t{ ...context, attributes: mergeAttributes(context.attributes, given) },\n\t\tfn,\n\t);\n}\n\n/** The span open right here, if there is one. */\nexport function currentSpan(): SpanContext | undefined {\n\treturn currentContext()?.span;\n}\n\n/** The header to send with an outgoing call, so the trace continues. */\nexport function currentTraceparent(): string | undefined {\n\tconst span = currentSpan();\n\treturn span === undefined ? undefined : renderTraceparent(span);\n}\n\n/** The attributes everything written here inherits. */\nexport function currentAttributes(): Attributes {\n\treturn currentContext()?.attributes ?? EMPTY_ATTRIBUTES;\n}\n\ninterface ContextStorage {\n\tgetStore(): TelemetryContext | undefined;\n\trun<T>(context: TelemetryContext, fn: () => T): T;\n}\n\n/**\n * A runtime with no `node:async_hooks` — a browser bundle, where the builtin is\n * shimmed away — falls back to a single variable. There is one request there,\n * so it is correct; it is the only mutable module-level context in this\n * library, and it exists so the package imports at all.\n */\nfunction createStorage(): ContextStorage {\n\tconst AsyncLocalStorage = asyncHooks.AsyncLocalStorage;\n\tif (typeof AsyncLocalStorage === 'function') {\n\t\treturn new AsyncLocalStorage<TelemetryContext>();\n\t}\n\n\tlet current: TelemetryContext | undefined;\n\treturn {\n\t\tgetStore: () => current,\n\t\trun<T>(context: TelemetryContext, fn: () => T): T {\n\t\t\tconst previous = current;\n\t\t\tcurrent = context;\n\t\t\ttry {\n\t\t\t\treturn fn();\n\t\t\t} finally {\n\t\t\t\tcurrent = previous;\n\t\t\t}\n\t\t},\n\t};\n}\n",
7
+ "import type { Resource, Signal } from '../model/signal';\nimport type { Exporter } from './exporter';\n\nexport interface PipelineOptions {\n\treadonly resource: Resource;\n\treadonly exporters: readonly Exporter[];\n\t/** Flush once this many signals are waiting. */\n\treadonly batch: number;\n\t/** Flush this many milliseconds after the first signal of a batch. */\n\treadonly linger: number;\n\t/** How long `close` waits for the backlog before giving up. */\n\treadonly drainTimeout: number;\n\treadonly onExportError: (failure: unknown) => void;\n}\n\n/**\n * The queue between everything that writes a signal and everything that ships\n * one.\n *\n * `post` is synchronous, total, and unbounded. A bounded queue would answer the\n * back-pressure question by dropping signals or by blocking the application,\n * and neither is an answer; an application that outruns its collector grows\n * this array, which is visible in a heap profile, rather than losing the\n * evidence of what it was doing.\n *\n * One consumer drains it, which is what lets the buffer be a plain array with\n * no locking and what makes a batch's order the order things happened in.\n */\nexport class Pipeline {\n\tprivate readonly options: PipelineOptions;\n\tprivate buffer: Signal[] = [];\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\t/** The single consumer: every flush is chained onto the previous one. */\n\tprivate draining: Promise<void> = Promise.resolve();\n\tprivate closed = false;\n\tprivate closing: Promise<void> | undefined;\n\n\tconstructor(options: PipelineOptions) {\n\t\tthis.options = options;\n\t}\n\n\t/**\n\t * Never blocks, never throws, and answers whether the signal was taken.\n\t * `false` means the pipeline is closed — the signal is dropped in silence,\n\t * because a log must not become the reason a shutdown fails.\n\t */\n\tpost(signal: Signal): boolean {\n\t\tif (this.closed) return false;\n\n\t\tthis.buffer.push(signal);\n\n\t\tif (this.buffer.length >= this.options.batch) {\n\t\t\tthis.flush();\n\t\t} else if (this.timer === undefined) {\n\t\t\tthis.timer = setTimeout(() => {\n\t\t\t\tthis.timer = undefined;\n\t\t\t\tthis.flush();\n\t\t\t}, this.options.linger);\n\t\t\t// A telemetry that is merely idle must not be the reason a process\n\t\t\t// will not exit.\n\t\t\tthis.timer.unref?.();\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Stops accepting signals, ships what is waiting, and closes every\n\t * exporter. Idempotent.\n\t *\n\t * It has to be awaited, and it is the one thing here that a caller waits\n\t * for: a close that returned before the backlog shipped would lose exactly\n\t * the signals a shutdown most needs to explain itself.\n\t *\n\t * **`drainTimeout` bounds the whole of it** — the drain and the exporters'\n\t * own `close` together — so neither a collector that stopped answering nor\n\t * an exporter that will not let go of its socket becomes the reason a\n\t * process will not exit. A drain that runs out of time is reported to\n\t * `onExportError`; see {@link Exporter} for what that suspends.\n\t */\n\tclose(): Promise<void> {\n\t\tthis.closing ??= this.drainAndClose();\n\t\treturn this.closing;\n\t}\n\n\tprivate flush(): void {\n\t\tthis.clearTimer();\n\t\tif (this.buffer.length === 0) return;\n\n\t\tconst batch = this.buffer;\n\t\tthis.buffer = [];\n\n\t\tthis.draining = this.draining.then(() => this.ship(batch));\n\t}\n\n\tprivate clearTimer(): void {\n\t\tif (this.timer === undefined) return;\n\t\tclearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t}\n\n\tprivate async ship(batch: readonly Signal[]): Promise<void> {\n\t\tfor (const exporter of this.options.exporters) {\n\t\t\ttry {\n\t\t\t\tawait exporter.export(this.options.resource, batch);\n\t\t\t} catch (failure) {\n\t\t\t\tthis.report(failure);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async drainAndClose(): Promise<void> {\n\t\tthis.closed = true;\n\t\tthis.flush();\n\n\t\t// One deadline for the whole close, started here. Bounding the drain\n\t\t// alone would leave an exporter whose own `close` never answers holding\n\t\t// a SIGTERM handler open for ever, which is the failure this is for.\n\t\tconst deadline = timeout(this.options.drainTimeout);\n\n\t\tconst drained = await Promise.race([\n\t\t\tthis.draining.then(() => true),\n\t\t\tdeadline.then(() => false),\n\t\t]);\n\n\t\tif (!drained) {\n\t\t\tthis.report(\n\t\t\t\tnew Error(\n\t\t\t\t\t`[telemetry] the backlog did not ship within ${this.options.drainTimeout}ms; closing anyway`,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\t// `closeExporters` never rejects, so racing it past the deadline leaves\n\t\t// a promise nobody awaits rather than an unhandled rejection.\n\t\tawait Promise.race([this.closeExporters(), deadline]);\n\t}\n\n\tprivate async closeExporters(): Promise<void> {\n\t\tfor (const exporter of this.options.exporters) {\n\t\t\ttry {\n\t\t\t\tawait exporter.close?.();\n\t\t\t} catch (failure) {\n\t\t\t\tthis.report(failure);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate report(failure: unknown): void {\n\t\ttry {\n\t\t\tthis.options.onExportError(failure);\n\t\t} catch {\n\t\t\t// A failing error handler is not worth a second failure. It is the\n\t\t\t// last place a signal could be lost, and losing it here is the\n\t\t\t// point: there is nowhere else to report to.\n\t\t}\n\t}\n}\n\nfunction timeout(milliseconds: number): Promise<void> {\n\treturn new Promise((resolve) => {\n\t\tconst timer = setTimeout(resolve, milliseconds);\n\t\ttimer.unref?.();\n\t});\n}\n",
7
8
  "/**\n * Trace identity, and the W3C `traceparent` header.\n *\n * The ids are branded strings: the hex representation is the representation, so\n * there is nothing to allocate and nothing to convert before writing a header,\n * and the brand still stops a span id being passed where a trace id belongs.\n */\n\ndeclare const traceIdBrand: unique symbol;\ndeclare const spanIdBrand: unique symbol;\n\n/** 32 lowercase hex characters. */\nexport type TraceId = string & { readonly [traceIdBrand]: true };\n\n/** 16 lowercase hex characters. */\nexport type SpanId = string & { readonly [spanIdBrand]: true };\n\nexport const INVALID_TRACE_ID = '0'.repeat(32) as TraceId;\nexport const INVALID_SPAN_ID = '0'.repeat(16) as SpanId;\n\nconst TRACE_ID_PATTERN = /^[0-9a-f]{32}$/;\nconst SPAN_ID_PATTERN = /^[0-9a-f]{16}$/;\nconst HEX_PATTERN = /^[0-9a-f]+$/;\n\nexport function isValidTraceId(hex: string): hex is TraceId {\n\treturn TRACE_ID_PATTERN.test(hex) && hex !== INVALID_TRACE_ID;\n}\n\nexport function isValidSpanId(hex: string): hex is SpanId {\n\treturn SPAN_ID_PATTERN.test(hex) && hex !== INVALID_SPAN_ID;\n}\n\n/**\n * From `crypto.getRandomValues`, never `Math.random()`: ids that collide join\n * two unrelated traces into one, which reads as a request that did work it\n * never did.\n */\nexport function randomTraceId(): TraceId {\n\treturn randomHex(16) as TraceId;\n}\n\nexport function randomSpanId(): SpanId {\n\treturn randomHex(8) as SpanId;\n}\n\n/** A span's place in a trace, as it travels. */\nexport interface SpanContext {\n\treadonly traceId: TraceId;\n\treadonly spanId: SpanId;\n\t/** Decided once, by the root, and inherited by everything below it. */\n\treadonly sampled: boolean;\n\t/** True when this context was parsed from an inbound header. */\n\treadonly remote: boolean;\n}\n\n/**\n * What a span carries when there is no telemetry installed. The block still\n * runs — a library that traces must work inside an application that has never\n * heard of this one — and nothing is emitted.\n */\nexport const DETACHED_SPAN_CONTEXT: SpanContext = Object.freeze({\n\ttraceId: INVALID_TRACE_ID,\n\tspanId: INVALID_SPAN_ID,\n\tsampled: false,\n\tremote: false,\n});\n\nexport function isDetached(context: SpanContext): boolean {\n\treturn !isValidTraceId(context.traceId);\n}\n\n/** `00-<trace id>-<span id>-<flags>`, version 00, the only one we write. */\nexport function renderTraceparent(context: SpanContext): string {\n\treturn `00-${context.traceId}-${context.spanId}-${context.sampled ? '01' : '00'}`;\n}\n\n/**\n * The inbound half. It **returns null, and never throws**: an unusable header\n * is a request that starts a fresh trace, not a request that fails.\n *\n * Rejected: fewer than four fields, a version that is not two characters, the\n * forbidden version `ff`, an id of the wrong length or all zeros or not hex,\n * and flags that are not hex. A later version is accepted and its extra fields\n * ignored, which is what the specification asks of a version-00 reader.\n *\n * `tracestate` is not read. Nothing here writes one either.\n */\nexport function parseTraceparent(\n\theader: string | null | undefined,\n): SpanContext | null {\n\tif (!header) return null;\n\n\tconst parts = header.trim().toLowerCase().split('-');\n\tif (parts.length < 4) return null;\n\n\tconst [version, traceId, spanId, flags] = parts as [\n\t\tstring,\n\t\tstring,\n\t\tstring,\n\t\tstring,\n\t];\n\n\tif (version.length !== 2 || !HEX_PATTERN.test(version) || version === 'ff') {\n\t\treturn null;\n\t}\n\tif (!isValidTraceId(traceId) || !isValidSpanId(spanId)) return null;\n\tif (!HEX_PATTERN.test(flags)) return null;\n\n\tconst parsed = Number.parseInt(flags, 16);\n\tif (Number.isNaN(parsed)) return null;\n\n\treturn {\n\t\ttraceId,\n\t\tspanId,\n\t\tsampled: (parsed & 0x01) === 0x01,\n\t\tremote: true,\n\t};\n}\n\nconst HEX = '0123456789abcdef';\n\nfunction randomHex(bytes: number): string {\n\tconst buffer = new Uint8Array(bytes);\n\tcrypto.getRandomValues(buffer);\n\n\tlet hex = '';\n\tfor (const byte of buffer) {\n\t\thex += HEX[byte >> 4];\n\t\thex += HEX[byte & 0x0f];\n\t}\n\treturn hex;\n}\n",
8
- "import { isValidTraceId, type TraceId } from './ids';\n\n/**\n * Sampling is decided once, by the root span, and the answer travels with the\n * trace — down through every child and out over the wire in the `traceparent`.\n * A sampler consulted per span produces traces missing their middles, and a gap\n * in a trace looks like work that never happened.\n *\n * Logs are not sampled. That decision is about the volume of traces, and a log\n * dropped because its trace was not kept is a log missing at precisely the\n * moment somebody is reading logs to find out what happened.\n */\nexport interface Sampler {\n\tsample(traceId: TraceId): boolean;\n}\n\nexport const alwaysSample: Sampler = { sample: () => true };\n\nexport const neverSample: Sampler = { sample: () => false };\n\nconst MAX_UINT64 = (1n << 64n) - 1n;\nconst SCALE = 1n << 53n;\n\n/**\n * Keep this fraction of traces, decided **from the trace id** rather than by a\n * coin toss: two services at the same ratio then make the same decision about\n * the same trace. Two services tossing independently at 10% keep a whole trace\n * 1% of the time.\n *\n * The rule is OpenTelemetry's — the low 64 bits of the trace id against\n * `ratio × 2⁶⁴` — so anything else implementing it agrees with us.\n *\n * @throws RangeError if `ratio` is not between 0 and 1. This is a construction\n * error, raised where the mistake is, and never on the path that writes a\n * signal.\n */\nexport function ratioSampler(ratio: number): Sampler {\n\tif (!Number.isFinite(ratio) || ratio < 0 || ratio > 1) {\n\t\tthrow new RangeError(`A sampling ratio is between 0 and 1, not ${ratio}`);\n\t}\n\tif (ratio === 0) return neverSample;\n\tif (ratio === 1) return alwaysSample;\n\n\tconst threshold =\n\t\t(BigInt(Math.round(ratio * Number(SCALE))) * MAX_UINT64) / SCALE;\n\n\treturn {\n\t\tsample(traceId: TraceId): boolean {\n\t\t\tif (!isValidTraceId(traceId)) return false;\n\t\t\treturn BigInt(`0x${traceId.slice(-16)}`) < threshold;\n\t\t},\n\t};\n}\n"
9
+ "import { isValidTraceId, type TraceId } from './ids';\n\n/**\n * Sampling is decided once, by the root span, and the answer travels with the\n * trace — down through every child and out over the wire in the `traceparent`.\n * A sampler consulted per span produces traces missing their middles, and a gap\n * in a trace looks like work that never happened.\n *\n * Logs are not sampled. That decision is about the volume of traces, and a log\n * dropped because its trace was not kept is a log missing at precisely the\n * moment somebody is reading logs to find out what happened.\n */\nexport interface Sampler {\n\tsample(traceId: TraceId): boolean;\n}\n\nexport const alwaysSample: Sampler = { sample: () => true };\n\nexport const neverSample: Sampler = { sample: () => false };\n\nconst MAX_UINT64 = (1n << 64n) - 1n;\nconst SCALE = 1n << 53n;\n\n/**\n * Keep this fraction of traces, decided **from the trace id** rather than by a\n * coin toss: two services at the same ratio then make the same decision about\n * the same trace. Two services tossing independently at 10% keep a whole trace\n * 1% of the time.\n *\n * The rule is OpenTelemetry's — the low 64 bits of the trace id against\n * `ratio × 2⁶⁴` — so anything else implementing it agrees with us.\n *\n * @throws RangeError if `ratio` is not between 0 and 1. This is a construction\n * error, raised where the mistake is, and never on the path that writes a\n * signal.\n */\nexport function ratioSampler(ratio: number): Sampler {\n\tif (!Number.isFinite(ratio) || ratio < 0 || ratio > 1) {\n\t\tthrow new RangeError(`A sampling ratio is between 0 and 1, not ${ratio}`);\n\t}\n\tif (ratio === 0) return neverSample;\n\tif (ratio === 1) return alwaysSample;\n\n\tconst threshold =\n\t\t(BigInt(Math.round(ratio * Number(SCALE))) * MAX_UINT64) / SCALE;\n\n\treturn {\n\t\tsample(traceId: TraceId): boolean {\n\t\t\tif (!isValidTraceId(traceId)) return false;\n\t\t\treturn BigInt(`0x${traceId.slice(-16)}`) < threshold;\n\t\t},\n\t};\n}\n",
10
+ "import { attributesOf } from '../attributes/attributes';\nimport type { Exporter } from '../export/exporter';\nimport { Pipeline } from '../export/pipeline';\nimport type { Resource, Severity, Signal } from '../model/signal';\nimport { alwaysSample, type Sampler } from '../trace/sampler';\n\nexport interface TelemetryOptions {\n\treadonly version?: string;\n\treadonly environment?: string;\n\t/** Stamped on the resource, so every signal carries them. */\n\treadonly attributes?: Readonly<Record<string, unknown>>;\n\t/** Asked once, for a root span. Default: `alwaysSample`. */\n\treadonly sampler?: Sampler;\n\t/** Logs below this are never built. Spans are unaffected. Default `info`. */\n\treadonly minimum?: Severity;\n\t/** Whether a recorded failure carries its stack. Default true. */\n\treadonly stackTraces?: boolean;\n\t/** Flush once this many signals are waiting. Default 512. */\n\treadonly batch?: number;\n\t/** Flush this long after the first signal of a batch, in ms. Default 1000. */\n\treadonly linger?: number;\n\t/** How long `close` waits for the backlog, in ms. Default 10000. */\n\treadonly drainTimeout?: number;\n\t/** Default: `console.error`. It must not throw; if it does, it is ignored. */\n\treadonly onExportError?: (failure: unknown) => void;\n\t/** In order. A batch reaches them one after the other. */\n\treadonly exporters?: readonly Exporter[];\n}\n\nexport const TELEMETRY_DEFAULTS = Object.freeze({\n\tminimum: 'info' as Severity,\n\tstackTraces: true,\n\tbatch: 512,\n\tlinger: 1_000,\n\tdrainTimeout: 10_000,\n});\n\nlet installed: Telemetry | undefined;\n\n/**\n * A service's telemetry: its resource, its sampler, and the pipeline its\n * signals go through.\n *\n * Build it with {@link createTelemetry}. `install()` makes it the one a logger\n * or a span finds when there is none in scope.\n */\nexport class Telemetry {\n\treadonly resource: Resource;\n\treadonly sampler: Sampler;\n\treadonly minimum: Severity;\n\treadonly stackTraces: boolean;\n\n\tprivate readonly pipeline: Pipeline;\n\n\tconstructor(options: TelemetryOptions & { readonly service: string }) {\n\t\tthis.resource = {\n\t\t\tservice: options.service,\n\t\t\t...(options.version === undefined ? {} : { version: options.version }),\n\t\t\t...(options.environment === undefined\n\t\t\t\t? {}\n\t\t\t\t: { environment: options.environment }),\n\t\t\tattributes: attributesOf(options.attributes),\n\t\t};\n\t\tthis.sampler = options.sampler ?? alwaysSample;\n\t\tthis.minimum = options.minimum ?? TELEMETRY_DEFAULTS.minimum;\n\t\tthis.stackTraces = options.stackTraces ?? TELEMETRY_DEFAULTS.stackTraces;\n\n\t\tthis.pipeline = new Pipeline({\n\t\t\tresource: this.resource,\n\t\t\texporters: options.exporters ?? [],\n\t\t\tbatch: options.batch ?? TELEMETRY_DEFAULTS.batch,\n\t\t\tlinger: options.linger ?? TELEMETRY_DEFAULTS.linger,\n\t\t\tdrainTimeout: options.drainTimeout ?? TELEMETRY_DEFAULTS.drainTimeout,\n\t\t\tonExportError: options.onExportError ?? defaultOnExportError,\n\t\t});\n\t}\n\n\t/** Never blocks, never throws. False once closed. */\n\temit(signal: Signal): boolean {\n\t\treturn this.pipeline.post(signal);\n\t}\n\n\t/** The one a logger or a span finds with nothing in scope. Returns itself. */\n\tinstall(): this {\n\t\tinstalled = this;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ships the backlog and closes the exporters. **It has to be awaited**:\n\t * JavaScript cannot block, so a process that exits without waiting loses\n\t * its last batch — which is the batch that explains the shutdown.\n\t *\n\t * Idempotent, and it stands down as the installed default.\n\t */\n\tasync close(): Promise<void> {\n\t\tif (installed === this) installed = undefined;\n\t\tawait this.pipeline.close();\n\t}\n\n\tasync [Symbol.asyncDispose](): Promise<void> {\n\t\tawait this.close();\n\t}\n}\n\n/**\n * ```ts\n * const telemetry = createTelemetry('checkout', {\n * environment: 'production',\n * sampler: ratioSampler(0.1),\n * exporters: [consoleExporter()],\n * }).install();\n * ```\n *\n * `service` has no default on purpose: it is the key everything groups by, and\n * a service called `unknown` is a dashboard nobody can read.\n */\nexport function createTelemetry(\n\tservice: string,\n\toptions: TelemetryOptions = {},\n): Telemetry {\n\treturn new Telemetry({ ...options, service });\n}\n\n/** The installed default, if `install()` has been called. */\nexport function installedTelemetry(): Telemetry | undefined {\n\treturn installed;\n}\n\n/**\n * Only for a test that needs the process back the way it found it. Production\n * code stands an instance down by closing it.\n */\nexport function uninstallTelemetry(telemetry?: Telemetry): void {\n\tif (telemetry === undefined || installed === telemetry) installed = undefined;\n}\n\nfunction defaultOnExportError(failure: unknown): void {\n\tconsole.error('[telemetry] export failed', failure);\n}\n",
11
+ "import type { Attributes, AttributeValue } from '../attributes/attributes';\nimport type {\n\tErrorInfo,\n\tLogRecord,\n\tResource,\n\tSignal,\n\tSpanRecord,\n} from '../model/signal';\nimport type { Exporter } from './exporter';\n\nexport interface ConsoleExporterOptions {\n\t/** Where a line goes. Default: `console.log`. */\n\treadonly write?: (line: string) => void;\n\t/** Whether a recorded stack is printed under the line. Default true. */\n\treadonly stackTraces?: boolean;\n}\n\n/**\n * One line per signal, for a terminal.\n *\n * ```\n * 10:04:22.318 INFO CheckoutService checkout.charged orderId=o-1 amount=4200 [4bf92f35/00f067aa]\n * 10:04:22.402 SPAN charge 84ms [4bf92f35/00f067aa]\n * ```\n *\n * Errors go to the same stream as everything else: a log split across two\n * streams is a log read in the wrong order.\n */\nexport function consoleExporter(\n\toptions: ConsoleExporterOptions = {},\n): Exporter {\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\tconst stackTraces = options.stackTraces ?? true;\n\n\treturn {\n\t\texport(_resource: Resource, batch: readonly Signal[]): void {\n\t\t\tfor (const signal of batch) {\n\t\t\t\twrite(signal.type === 'log' ? renderLog(signal) : renderSpan(signal));\n\n\t\t\t\tconst error = signal.error;\n\t\t\t\tif (stackTraces && error?.stackTrace) write(error.stackTrace);\n\t\t\t}\n\t\t},\n\t};\n}\n\nfunction renderLog(log: LogRecord): string {\n\treturn [\n\t\tclock(log.at),\n\t\tlog.severity.toUpperCase().padEnd(5),\n\t\tlog.source,\n\t\tlog.name,\n\t\trenderAttributes(log.attributes),\n\t\trenderError(log.error),\n\t\trenderTrace(log),\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n}\n\nfunction renderSpan(span: SpanRecord): string {\n\treturn [\n\t\tclock(span.endedAt),\n\t\t'SPAN ',\n\t\tspan.name,\n\t\t`${span.endedAt - span.startedAt}ms`,\n\t\tspan.status === 'ok' ? '' : span.status.toUpperCase(),\n\t\trenderAttributes(span.attributes),\n\t\trenderError(span.error),\n\t\trenderTrace(span),\n\t]\n\t\t.filter(Boolean)\n\t\t.join(' ');\n}\n\nfunction clock(at: number): string {\n\t// `toISOString` throws on an instant outside the range a Date can hold, and\n\t// a throw here would cost every signal after it in the batch. Nothing in\n\t// this library refuses a value.\n\tif (!Number.isFinite(at) || Math.abs(at) > 8.64e15) return String(at);\n\treturn new Date(at).toISOString().slice(11, 23);\n}\n\nfunction renderAttributes(attributes: Attributes): string {\n\treturn Object.entries(attributes)\n\t\t.map(([key, value]) => `${key}=${renderValue(value)}`)\n\t\t.join(' ');\n}\n\nfunction renderValue(value: AttributeValue): string {\n\treturn Array.isArray(value) ? `[${value.join(',')}]` : String(value);\n}\n\nfunction renderError(error: ErrorInfo | undefined): string {\n\tif (error === undefined) return '';\n\treturn error.message ? `${error.type}: ${error.message}` : error.type;\n}\n\nfunction renderTrace(signal: Signal): string {\n\tconst span = signal.type === 'log' ? signal.span : signal.context;\n\tif (span === undefined) return '';\n\treturn `[${span.traceId.slice(0, 8)}/${span.spanId.slice(0, 8)}]`;\n}\n",
12
+ "import {\n\tappendFile,\n\tmkdir,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\tstat,\n\twriteFile,\n} from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { promisify } from 'node:util';\nimport { gzip } from 'node:zlib';\nimport type { Resource, Signal } from '../model/signal';\nimport type { Exporter } from './exporter';\nimport {\n\tprunable,\n\ttype RotationPolicy,\n\trolledName,\n\trotationDue,\n} from './rotation';\n\nconst compressed = promisify(gzip);\n\n/** 64 MiB. */\nexport const DEFAULT_MAX_SIZE = 64 * 1024 * 1024;\n/** 24 hours, in milliseconds. Epoch-aligned, so it rolls at UTC midnight. */\nexport const DEFAULT_ROTATION_PERIOD = 24 * 60 * 60 * 1000;\n/** How many archives may share one second before a roll gives up. */\nconst MAX_COLLISIONS = 1_000;\n\nexport interface FileExporterOptions {\n\t/** The file to append to. Its directory is created if it is missing. */\n\treadonly path: string;\n\t/** Roll at this many bytes. `0` disables it. Default 64 MiB. */\n\treadonly maxSize?: number;\n\t/** Roll when this period changes, in ms. `0` disables it. Default 24h. */\n\treadonly every?: number;\n\t/** How many rolled files to keep. Default 7. */\n\treadonly keep?: number;\n\t/** Gzip a rolled file. Default false. */\n\treadonly compress?: boolean;\n\t/** For specs. Default `Date.now`. */\n\treadonly now?: () => number;\n}\n\n/**\n * One JSON object per signal, appended to a file, with rotation.\n *\n * ```ts\n * fileExporter({ path: 'logs/telemetry.jsonl', every: 0, maxSize: 8 * 1024 * 1024 })\n * ```\n *\n * The same line format as `jsonLinesExporter`, so a shipper reads either. It\n * **appends**: a restart continues the current file, and the period is read\n * from that file's modification time rather than from when this process\n * started, so a service that restarts hourly still rolls once a day.\n *\n * `close()` rolls nothing. A rolled file is a finished period, and a shutdown is\n * not one.\n *\n * **This exporter owns its path.** It is the one stateful exporter here — it\n * remembers the file's size and age rather than asking the filesystem on every\n * batch — so give each path exactly one exporter. Calls are serialised\n * internally, and any failure throws away what it remembered, so an external\n * `logrotate` or a full disk costs the batch it happened on and nothing after\n * it.\n */\nexport function fileExporter(options: FileExporterOptions): Exporter {\n\tconst policy: RotationPolicy = {\n\t\tmaxSize: options.maxSize ?? DEFAULT_MAX_SIZE,\n\t\tevery: options.every ?? DEFAULT_ROTATION_PERIOD,\n\t\tkeep: options.keep ?? 7,\n\t\tcompress: options.compress ?? false,\n\t};\n\tconst now = options.now ?? Date.now;\n\tconst path = options.path;\n\n\tlet state: { size: number; openedAt: number } | undefined;\n\tlet queue: Promise<unknown> = Promise.resolve();\n\n\tconst write = async (batch: readonly Signal[]): Promise<void> => {\n\t\tconst text = render(batch);\n\t\tif (text.length === 0) return;\n\n\t\ttry {\n\t\t\t// Whatever we remember is only a cache of the filesystem, and it is\n\t\t\t// re-derived after any failure: a roll that threw would otherwise\n\t\t\t// leave `size` above `maxSize` for ever, so every later batch would\n\t\t\t// try to rename a file that is no longer there, and the process\n\t\t\t// would look healthy while writing nothing.\n\t\t\tstate ??= await currentState(path, now());\n\n\t\t\tif (rotationDue(state.size, state.openedAt, now(), policy)) {\n\t\t\t\tawait roll(path, now(), policy);\n\t\t\t\tstate = { size: 0, openedAt: now() };\n\t\t\t}\n\n\t\t\tawait appendFile(path, text, 'utf8');\n\t\t\tstate.size += Buffer.byteLength(text, 'utf8');\n\t\t} catch (failure) {\n\t\t\tstate = undefined;\n\t\t\tthrow failure;\n\t\t}\n\t};\n\n\treturn {\n\t\texport(_resource: Resource, batch: readonly Signal[]): Promise<void> {\n\t\t\t// The pipeline never calls an exporter twice at once, but a second\n\t\t\t// telemetry — or a caller holding this exporter — could. The chain\n\t\t\t// makes that safe rather than interleaved.\n\t\t\tconst next = queue.then(() => write(batch));\n\t\t\tqueue = next.catch(() => undefined);\n\t\t\treturn next;\n\t\t},\n\t};\n}\n\nfunction render(batch: readonly Signal[]): string {\n\tlet text = '';\n\tfor (const signal of batch) {\n\t\ttry {\n\t\t\ttext += `${JSON.stringify(signal)}\\n`;\n\t\t} catch {\n\t\t\t// One signal that will not serialise must not cost the rest.\n\t\t}\n\t}\n\treturn text;\n}\n\n/**\n * The size and age of the file we are about to append to. A file that is not\n * there yet is size 0 opened now; its **modification time** is when the current\n * period started, which is what makes a restart continue rather than reset.\n */\nasync function currentState(\n\tpath: string,\n\tfallback: number,\n): Promise<{ size: number; openedAt: number }> {\n\tawait mkdir(dirname(path), { recursive: true });\n\n\ttry {\n\t\tconst found = await stat(path);\n\t\treturn { size: found.size, openedAt: found.mtimeMs };\n\t} catch {\n\t\treturn { size: 0, openedAt: fallback };\n\t}\n}\n\nasync function roll(\n\tpath: string,\n\tat: number,\n\tpolicy: RotationPolicy,\n): Promise<void> {\n\tconst target = await freeName(path, at);\n\tawait rename(path, target);\n\n\tif (policy.compress) await compress(target);\n\tawait prune(path, policy.keep);\n}\n\n/** Two rolls in the same second are possible; `-1`, `-2`… keep both. */\nasync function freeName(path: string, at: number): Promise<string> {\n\tfor (let taken = 0; taken < MAX_COLLISIONS; taken++) {\n\t\tconst candidate = rolledName(path, at, taken);\n\t\tif (!(await exists(candidate)) && !(await exists(`${candidate}.gz`))) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\t// Renaming onto the thousandth name would destroy that archive in silence.\n\t// Failing the batch is reported, and the next one re-reads the directory.\n\tthrow new Error(\n\t\t`[telemetry] ${MAX_COLLISIONS} archives of ${path} already share this second`,\n\t);\n}\n\n/**\n * Compress in place: the archive is written under a temporary name and moved\n * over, so a reader never sees a half-written `.gz`. If the plain file survives\n * the cleanup, `rolledOf` folds the pair back into one period rather than\n * counting it twice and pruning a period early.\n */\nasync function compress(path: string): Promise<void> {\n\tconst pending = `${path}.gz.pending`;\n\tawait writeFile(pending, await compressed(await readFile(path)));\n\tawait rename(pending, `${path}.gz`);\n\tawait rm(path, { force: true });\n}\n\nasync function prune(path: string, keep: number): Promise<void> {\n\tconst directory = dirname(path);\n\tconst names = await readdir(directory);\n\n\tfor (const name of prunable(path, names, keep)) {\n\t\tawait rm(join(directory, name), { force: true });\n\t}\n}\n\nasync function exists(path: string): Promise<boolean> {\n\treturn stat(path).then(\n\t\t() => true,\n\t\t() => false,\n\t);\n}\n",
13
+ "import { basename } from 'node:path';\n\nexport interface RotationPolicy {\n\t/** Roll once the file is at least this many bytes. 0 disables it. */\n\treadonly maxSize: number;\n\t/** Roll when this many milliseconds' period changes. 0 disables it. */\n\treadonly every: number;\n\t/** How many rolled files to keep. 0 keeps none. */\n\treadonly keep: number;\n\treadonly compress: boolean;\n}\n\n/**\n * Whether the file open since `openedAt` should be rolled before the next\n * write.\n *\n * **An empty file is never rolled**, whatever the clock says: rolling one\n * produces an empty archive and resets the period, so an idle service would\n * accumulate a directory of nothing.\n *\n * The period is **epoch-aligned** rather than measured from when the file was\n * opened: `every: 24h` then rolls at UTC midnight, which is what somebody\n * reading yesterday's file expects, instead of 24 hours after a restart.\n */\nexport function rotationDue(\n\tsize: number,\n\topenedAt: number,\n\tnow: number,\n\tpolicy: RotationPolicy,\n): boolean {\n\tif (size <= 0) return false;\n\tif (policy.maxSize > 0 && size >= policy.maxSize) return true;\n\treturn policy.every > 0 && period(openedAt, policy) !== period(now, policy);\n}\n\n/**\n * `telemetry.jsonl` rolled at that instant becomes\n * `telemetry-20260915-100422.jsonl`, and `-1`, `-2`… if that name is taken.\n * UTC, and no colons: the name has to survive every filesystem.\n */\nexport function rolledName(path: string, at: number, taken = 0): string {\n\tconst file = basename(path);\n\tconst directory = path.slice(0, path.length - file.length);\n\n\tconst dot = file.lastIndexOf('.');\n\tconst base = dot <= 0 ? file : file.slice(0, dot);\n\tconst extension = dot <= 0 ? '' : file.slice(dot);\n\n\tconst suffix = taken === 0 ? '' : `-${taken}`;\n\treturn `${directory}${base}-${stamp(at)}${suffix}${extension}`;\n}\n\n/**\n * The rolled files of `path`, **newest first**. Anything else — the live file,\n * another service's archives — is left alone.\n *\n * The order is taken from the parsed stamp and collision number, not from the\n * name as text. Sorting the names would be wrong twice over within one second:\n * the suffix is not fixed-width, so `-9` sorts after `-12`, and the unsuffixed\n * name — which is the *oldest* of that second — sorts after every suffixed one,\n * because `.` is above `-`.\n *\n * A gzipped archive and its plain twin are one period, and only the archive is\n * listed: a `compress` whose cleanup failed must not make `keep` prune a period\n * early.\n */\nexport function rolledOf(path: string, names: readonly string[]): string[] {\n\tconst found = new Map<string, { name: string; at: string; taken: number }>();\n\n\tfor (const name of names) {\n\t\tconst rolled = parse(path, name);\n\t\tif (rolled === undefined) continue;\n\n\t\tconst key = `${rolled.at}-${rolled.taken}`;\n\t\tconst seen = found.get(key);\n\t\t// A `.gz` and its plain twin are the same period; prefer the archive.\n\t\tif (seen === undefined || name.endsWith('.gz')) {\n\t\t\tfound.set(key, { ...rolled, name });\n\t\t}\n\t}\n\n\treturn [...found.values()]\n\t\t.sort(\n\t\t\t(one, other) => other.at.localeCompare(one.at) || other.taken - one.taken,\n\t\t)\n\t\t.map((rolled) => rolled.name);\n}\n\n/** Which rolled files to delete, given how many to keep. */\nexport function prunable(\n\tpath: string,\n\tnames: readonly string[],\n\tkeep: number,\n): string[] {\n\tconst kept = new Set(rolledOf(path, names).slice(0, Math.max(keep, 0)));\n\t// Everything that belongs to this file and is not kept, including the plain\n\t// twin of an archive `rolledOf` folded away.\n\treturn names.filter(\n\t\t(name) => parse(path, name) !== undefined && !kept.has(name),\n\t);\n}\n\nfunction period(at: number, policy: RotationPolicy): number {\n\treturn Math.floor(at / policy.every);\n}\n\nfunction parse(\n\tpath: string,\n\tname: string,\n): { at: string; taken: number } | undefined {\n\tconst file = basename(path);\n\tconst dot = file.lastIndexOf('.');\n\tconst base = dot <= 0 ? file : file.slice(0, dot);\n\tconst extension = dot <= 0 ? '' : file.slice(dot);\n\n\tconst pattern = new RegExp(\n\t\t`^${escapeRegex(base)}-(\\\\d{8}-\\\\d{6})(?:-(\\\\d+))?${escapeRegex(extension)}(\\\\.gz)?$`,\n\t);\n\n\tconst found = pattern.exec(name);\n\tif (found === null) return undefined;\n\n\treturn { at: found[1] as string, taken: Number(found[2] ?? 0) };\n}\n\nfunction stamp(at: number): string {\n\tconst iso = new Date(at).toISOString();\n\treturn `${iso.slice(0, 10).replaceAll('-', '')}-${iso.slice(11, 19).replaceAll(':', '')}`;\n}\n\nfunction escapeRegex(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n",
14
+ "import type { Resource, Signal } from '../model/signal';\nimport type { Exporter } from './exporter';\n\nexport interface JsonLinesExporterOptions {\n\t/** Where a line goes. Default: `console.log`. */\n\treadonly write?: (line: string) => void;\n}\n\n/**\n * One JSON object per signal, one per line — the format `jq`, a log shipper and\n * a collector's file receiver all read.\n *\n * The line is the signal as it is: `type` discriminates `\"log\"` from `\"span\"`,\n * instants are epoch milliseconds, and absent fields are absent rather than\n * null. **It does not carry the resource.** A file belongs to one service, so\n * repeating its name on every line would be noise; an exporter that writes\n * somewhere shared — `@nxgt/telemetry-mongo` — stamps it instead.\n */\nexport function jsonLinesExporter(\n\toptions: JsonLinesExporterOptions = {},\n): Exporter {\n\tconst write = options.write ?? ((line: string) => console.log(line));\n\n\treturn {\n\t\texport(_resource: Resource, batch: readonly Signal[]): void {\n\t\t\tfor (const signal of batch) {\n\t\t\t\tconst line = render(signal);\n\t\t\t\tif (line !== undefined) write(line);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/** One signal that will not serialise must not cost the rest of the batch. */\nfunction render(signal: Signal): string | undefined {\n\ttry {\n\t\treturn JSON.stringify(signal);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n",
15
+ "import {\n\ttype Attributes,\n\tattributesOf,\n\tcoerceAttribute,\n} from '../attributes/attributes';\nimport type { InferInput, StandardSchemaV1 } from './standard-schema';\n\n/** A named thing that happened, with the fields its type declares. */\nexport interface TelemetryEvent {\n\treadonly name: string;\n\treadonly attributes: Attributes;\n\t/** True when the schema refused the input and the fields were read as-is. */\n\treadonly invalid?: boolean;\n}\n\n/** The marker an invalid event carries, so it can be found and fixed. */\nexport const INVALID_EVENT_ATTRIBUTE = 'telemetry.event.invalid';\n\nexport function event(\n\tname: string,\n): (input?: Readonly<Record<string, unknown>>) => TelemetryEvent;\n\nexport function event<Schema extends StandardSchemaV1>(\n\tname: string,\n\tschema: Schema,\n): (input: InferInput<Schema>) => TelemetryEvent;\n\n/**\n * Declares an event type.\n *\n * ```ts\n * const Charged = event('checkout.charged', z.object({ orderId: z.string(), amount: z.number() }));\n *\n * log.info(Charged({ orderId, amount }));\n * ```\n *\n * Declaring what you log makes **choosing what is logged the same act as\n * writing the code**, rather than a redaction list somebody has to keep up to\n * date. Logging an object as it is logs the field added next quarter — the card\n * number included — and nobody finds out, because a log that says too much\n * still looks like a working log.\n *\n * The schema is the declaration, and what it returns is what is emitted: an\n * object schema's unknown keys are gone by the time this does. Any Standard\n * Schema will do — Zod, Valibot, ArkType — and none of them is a dependency\n * here.\n *\n * **It never throws.** A schema that refuses the input, or one that answers\n * asynchronously, still produces an event: the readable fields, plus\n * `telemetry.event.invalid`. A log call is a total function.\n */\nexport function event(\n\tname: string,\n\tschema?: StandardSchemaV1,\n): (input?: never) => TelemetryEvent {\n\treturn ((input?: Readonly<Record<string, unknown>>): TelemetryEvent => {\n\t\tif (schema === undefined) return { name, attributes: attributesOf(input) };\n\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = schema['~standard'].validate(input);\n\t\t} catch {\n\t\t\treturn invalid(name, input);\n\t\t}\n\n\t\tif (isThenable(result)) {\n\t\t\t// Nothing here may await: `log.info` is called from constructors and\n\t\t\t// from `catch` blocks, where an async logger cannot be called at all.\n\t\t\tvoid Promise.resolve(result).catch(() => undefined);\n\t\t\treturn invalid(name, input);\n\t\t}\n\n\t\tconst checked = result as { value?: unknown; issues?: readonly unknown[] };\n\t\tif (checked.issues !== undefined) return invalid(name, input);\n\n\t\treturn { name, attributes: fields(checked.value) };\n\t}) as (input?: never) => TelemetryEvent;\n}\n\nexport function isTelemetryEvent(value: unknown): value is TelemetryEvent {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as TelemetryEvent).name === 'string' &&\n\t\ttypeof (value as TelemetryEvent).attributes === 'object'\n\t);\n}\n\nfunction invalid(\n\tname: string,\n\tinput: Readonly<Record<string, unknown>> | undefined,\n): TelemetryEvent {\n\treturn {\n\t\tname,\n\t\tattributes: { ...attributesOf(input), [INVALID_EVENT_ATTRIBUTE]: true },\n\t\tinvalid: true,\n\t};\n}\n\n/** A schema may return something that is not a record; it still has to log. */\nfunction fields(value: unknown): Attributes {\n\tif (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n\t\treturn attributesOf(value as Record<string, unknown>);\n\t}\n\treturn { value: coerceAttribute(value) };\n}\n\nfunction isThenable(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { then?: unknown }).then === 'function'\n\t);\n}\n",
16
+ "import { UNREADABLE } from '../attributes/attributes';\nimport type { ErrorInfo } from './signal';\n\n/**\n * A thrown value, flattened onto the wire.\n *\n * **Nothing here can throw.** `throw` accepts anything — a string, a Proxy, an\n * `Error` subclass with a getter that raises, an object from another realm —\n * and this runs inside a `catch`, where a second failure would replace the\n * application's first one and lose it. Every property read is guarded, and a\n * value it cannot read at all still produces a record.\n */\nexport function errorInfo(failure: unknown, stackTraces = true): ErrorInfo {\n\ttry {\n\t\treturn flatten(failure, stackTraces);\n\t} catch {\n\t\treturn { type: 'Error', message: UNREADABLE };\n\t}\n}\n\n/**\n * Whether a failure is work that was called off rather than work that broke.\n *\n * `cancelled` is a status of its own so that a shutdown and a timeout do not\n * read as failures — a dashboard that counts them as such is a dashboard nobody\n * trusts. `AbortError` is what an `AbortSignal` rejects with, and `TimeoutError`\n * is what `AbortSignal.timeout` rejects with.\n */\nexport function isAbort(failure: unknown): boolean {\n\tif (typeof failure !== 'object' || failure === null) return false;\n\tconst name = read(failure, 'name');\n\treturn name === 'AbortError' || name === 'TimeoutError';\n}\n\nfunction flatten(failure: unknown, stackTraces: boolean): ErrorInfo {\n\tif (isError(failure)) {\n\t\tconst message = read(failure, 'message');\n\t\tconst stack = stackTraces ? read(failure, 'stack') : undefined;\n\n\t\treturn {\n\t\t\ttype: errorType(failure),\n\t\t\t...(typeof message === 'string' && message ? { message } : {}),\n\t\t\t...(typeof stack === 'string' && stack ? { stackTrace: stack } : {}),\n\t\t};\n\t}\n\n\treturn { type: typeName(failure), message: describe(failure) };\n}\n\n/**\n * `instanceof` is realm-bound: an `Error` from a worker, a `vm` context or an\n * iframe is not an instance of *this* realm's `Error`, and falling through to\n * the generic branch would render it `{}` — losing the message and the stack at\n * the one moment they matter.\n */\nfunction isError(value: unknown): value is object {\n\ttry {\n\t\tif (value instanceof Error) return true;\n\t\treturn (\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\tObject.prototype.toString.call(value) === '[object Error]'\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * `exception.type` is the field a dashboard groups failures by, so\n * `class ChargeRefused extends Error {}` must not read as `Error` — and it\n * would, because `name` is inherited unless the subclass assigns it. The class\n * name is what `stx-telemetry` records, and the two estates have to agree.\n */\nfunction errorType(failure: object): string {\n\tconst name = read(failure, 'name');\n\tconst named = typeof name === 'string' && name ? name : undefined;\n\tif (named !== undefined && named !== 'Error') return named;\n\n\tconst constructed = constructorName(failure);\n\tif (constructed !== undefined && constructed !== 'Object') return constructed;\n\n\treturn named ?? 'Error';\n}\n\nfunction typeName(failure: unknown): string {\n\tif (failure === null) return 'null';\n\tif (typeof failure !== 'object') return typeof failure;\n\treturn constructorName(failure) ?? 'Object';\n}\n\nfunction constructorName(value: object): string | undefined {\n\tconst name = read(value, 'constructor');\n\tif (typeof name !== 'function' && typeof name !== 'object') return undefined;\n\tif (name === null) return undefined;\n\n\tconst own = read(name, 'name');\n\treturn typeof own === 'string' && own ? own : undefined;\n}\n\nfunction read(value: object, key: string): unknown {\n\ttry {\n\t\treturn (value as Record<string, unknown>)[key];\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction describe(failure: unknown): string {\n\ttry {\n\t\treturn typeof failure === 'object' && failure !== null\n\t\t\t? JSON.stringify(failure) || String(failure)\n\t\t\t: String(failure);\n\t} catch {\n\t\treturn UNREADABLE;\n\t}\n}\n",
17
+ "import type { Attributes } from '../attributes/attributes';\nimport type { SpanContext, SpanId } from '../trace/ids';\n\n/**\n * The signal model. It is shared with `stx-telemetry`, the Kotlin counterpart:\n * the same four severities, the same span kinds and statuses, the same\n * discriminator. Changing anything here means the two estates have diverged.\n *\n * Instants are epoch **milliseconds**, which is the precision a JavaScript wall\n * clock has. OTLP wants nanoseconds, and the exporter multiplies.\n */\n\n/**\n * Four levels, and there is no `trace`: detail below `debug` is an attribute on\n * a span, where it is attached to the work it describes rather than to a line\n * somebody has to correlate by hand.\n */\nexport type Severity = 'debug' | 'info' | 'warn' | 'error';\n\n/** OTLP's numbers, which is what makes a backend order them correctly. */\nexport const SEVERITY_NUMBER: Readonly<Record<Severity, number>> =\n\tObject.freeze({\n\t\tdebug: 5,\n\t\tinfo: 9,\n\t\twarn: 13,\n\t\terror: 17,\n\t});\n\n/** Ascending, so a floor can be compared by index as well as by number. */\nexport const SEVERITIES: readonly Severity[] = Object.freeze([\n\t'debug',\n\t'info',\n\t'warn',\n\t'error',\n] as const);\n\n/** Whether `severity` clears the `minimum` floor. */\nexport function meetsSeverity(severity: Severity, minimum: Severity): boolean {\n\treturn SEVERITY_NUMBER[severity] >= SEVERITY_NUMBER[minimum];\n}\n\nexport type SpanKind =\n\t| 'internal'\n\t| 'server'\n\t| 'client'\n\t| 'producer'\n\t| 'consumer';\n\nexport const SPAN_KIND_NUMBER: Readonly<Record<SpanKind, number>> =\n\tObject.freeze({\n\t\tinternal: 1,\n\t\tserver: 2,\n\t\tclient: 3,\n\t\tproducer: 4,\n\t\tconsumer: 5,\n\t});\n\n/**\n * `cancelled` is distinct from `error` on purpose: a shutdown and a timeout are\n * not failures, and a dashboard that counts them as such is a dashboard nobody\n * trusts.\n */\nexport type SpanStatus = 'ok' | 'error' | 'cancelled';\n\n/** What every signal from one telemetry is about. */\nexport interface Resource {\n\treadonly service: string;\n\treadonly version?: string;\n\treadonly environment?: string;\n\treadonly attributes: Attributes;\n}\n\n/** A failure, flattened: the stack is text, because it crosses the wire. */\nexport interface ErrorInfo {\n\treadonly type: string;\n\treadonly message?: string;\n\treadonly stackTrace?: string;\n}\n\nexport interface LogRecord {\n\treadonly type: 'log';\n\t/** Epoch milliseconds. */\n\treadonly at: number;\n\treadonly severity: Severity;\n\t/** The event's name, or the message when there is no type for it yet. */\n\treadonly name: string;\n\t/** The logger's name. It becomes the OTLP instrumentation scope. */\n\treadonly source: string;\n\treadonly attributes: Attributes;\n\t/** Absent for a log written outside any span. */\n\treadonly span?: SpanContext;\n\treadonly error?: ErrorInfo;\n}\n\nexport interface SpanEvent {\n\treadonly name: string;\n\t/** Epoch milliseconds. */\n\treadonly at: number;\n\treadonly attributes: Attributes;\n}\n\nexport interface SpanRecord {\n\treadonly type: 'span';\n\treadonly name: string;\n\treadonly context: SpanContext;\n\t/** Absent for a root span. */\n\treadonly parent?: SpanId;\n\treadonly kind: SpanKind;\n\t/** Epoch milliseconds. */\n\treadonly startedAt: number;\n\t/** Epoch milliseconds. */\n\treadonly endedAt: number;\n\treadonly status: SpanStatus;\n\treadonly attributes: Attributes;\n\treadonly events: readonly SpanEvent[];\n\treadonly error?: ErrorInfo;\n}\n\n/**\n * The discriminator is the field `type`, with the values `\"log\"` and `\"span\"`.\n * It is not a class name, so that metrics can arrive as a third variant without\n * anything in the model or in the `Exporter` contract changing.\n */\nexport type Signal = LogRecord | SpanRecord;\n\n/** When a signal happened, whichever kind it is. */\nexport function signalAt(signal: Signal): number {\n\treturn signal.type === 'log' ? signal.at : signal.startedAt;\n}\n\n/** The span a signal belongs to, whichever kind it is. */\nexport function signalSpan(signal: Signal): SpanContext | undefined {\n\treturn signal.type === 'log' ? signal.span : signal.context;\n}\n",
18
+ "import {\n\ttype Attributes,\n\tattributesOf,\n\tEMPTY_ATTRIBUTES,\n\tmergeAttributes,\n} from '../attributes/attributes';\nimport {\n\tcurrentAttributes,\n\tcurrentSpan,\n\tresolveTelemetry,\n} from '../context/current';\nimport { errorInfo } from '../model/error';\nimport { type LogRecord, meetsSeverity, type Severity } from '../model/signal';\nimport { isTelemetryEvent, type TelemetryEvent } from './event';\n\ntype Fields = Readonly<Record<string, unknown>>;\n\n/** A message, a declared event, or a message that is only built if it is wanted. */\nexport type LogInput = string | TelemetryEvent | (() => string);\n\n/** A message or a declared event. The lazy form is for `debug` and `info` only. */\nexport type Reported = string | TelemetryEvent;\n\n/**\n * Writing a log never waits and never fails.\n *\n * Every method here is synchronous and total. With no telemetry installed the\n * line is dropped in silence — a library that logs must work inside an\n * application that has never heard of this one. Below the severity floor\n * nothing is built at all, which is what makes the lazy form worth having.\n */\nexport interface Logger {\n\t/** Whether anything would come of a log at this level, right here. */\n\tenabled(severity: Severity): boolean;\n\n\tdebug(input: LogInput, attributes?: Fields): void;\n\tinfo(input: LogInput, attributes?: Fields): void;\n\n\twarn(input: Reported, attributes?: Fields): void;\n\twarn(input: Reported, failure: unknown, attributes?: Fields): void;\n\n\terror(input: Reported, attributes?: Fields): void;\n\terror(input: Reported, failure: unknown, attributes?: Fields): void;\n}\n\n/**\n * ```ts\n * const log = createLogger('CheckoutService');\n *\n * log.info(Charged({ orderId, amount })); // a declared event\n * log.warn('charge refused', { orderId, code }); // ad hoc, for what has no type yet\n * log.debug(() => `state: ${expensive()}`); // built only if debug is on\n * log.error('charge failed', failure, { orderId });\n * ```\n *\n * `source` is the logger's name — a class, a module, whatever groups these\n * lines. It becomes the instrumentation scope an OTLP backend shows.\n *\n * The telemetry is resolved **at each call**, scope first and installed second.\n * That is what lets two suites in one process each collect their own signals,\n * and it is why a logger can be built at module scope before anything is\n * installed.\n */\nexport function createLogger(source: string): Logger {\n\tconst write = (\n\t\tseverity: Severity,\n\t\tinput: LogInput,\n\t\tsecond?: unknown,\n\t\tthird?: Fields,\n\t): void => {\n\t\tconst telemetry = resolveTelemetry();\n\t\tif (telemetry === undefined) return;\n\t\tif (!meetsSeverity(severity, telemetry.minimum)) return;\n\n\t\tconst [failure, fields] = split(second, third);\n\t\tconst span = currentSpan();\n\t\tconst named = name(input);\n\n\t\tconst record: LogRecord = {\n\t\t\ttype: 'log',\n\t\t\tat: Date.now(),\n\t\t\tseverity,\n\t\t\tname: named.name,\n\t\t\tsource,\n\t\t\tattributes: mergeAttributes(\n\t\t\t\tmergeAttributes(currentAttributes(), named.attributes),\n\t\t\t\tattributesOf(fields),\n\t\t\t),\n\t\t\t...(span === undefined ? {} : { span }),\n\t\t\t...(failure === undefined\n\t\t\t\t? {}\n\t\t\t\t: { error: errorInfo(failure, telemetry.stackTraces) }),\n\t\t};\n\n\t\ttelemetry.emit(record);\n\t};\n\n\treturn {\n\t\tenabled(severity: Severity): boolean {\n\t\t\tconst telemetry = resolveTelemetry();\n\t\t\treturn (\n\t\t\t\ttelemetry !== undefined && meetsSeverity(severity, telemetry.minimum)\n\t\t\t);\n\t\t},\n\t\tdebug: (input, attributes) => write('debug', input, attributes),\n\t\tinfo: (input, attributes) => write('info', input, attributes),\n\t\twarn: (input, second?: unknown, third?: Fields) =>\n\t\t\twrite('warn', input, second, third),\n\t\terror: (input, second?: unknown, third?: Fields) =>\n\t\t\twrite('error', input, second, third),\n\t};\n}\n\n/**\n * `warn(message, attributes)` and `warn(message, failure, attributes)` are the\n * same call at runtime. A plain record is attributes; anything else — an\n * `Error`, a string, a rejected value — is the failure, because nobody passes\n * one of those as a bag of fields.\n */\nfunction split(\n\tsecond: unknown,\n\tthird: Fields | undefined,\n): [failure: unknown, fields: Fields | undefined] {\n\tif (third !== undefined) return [second, third];\n\tif (second === undefined) return [undefined, undefined];\n\treturn isFields(second) ? [undefined, second] : [second, undefined];\n}\n\nfunction isFields(value: unknown): value is Fields {\n\tif (typeof value !== 'object' || value === null) return false;\n\n\ttry {\n\t\tif (value instanceof Error || Array.isArray(value)) return false;\n\n\t\tconst prototype = Object.getPrototypeOf(value);\n\t\tif (prototype === null || prototype === Object.prototype) return true;\n\n\t\t// Another realm's `Object.prototype` is not ours, but it is still the\n\t\t// root of its own chain and its constructor is still called `Object`.\n\t\t// Without this a plain object from a worker reads as a failure, and its\n\t\t// fields stop being indexable.\n\t\treturn (\n\t\t\tObject.getPrototypeOf(prototype) === null &&\n\t\t\t(prototype as { constructor?: { name?: unknown } }).constructor?.name ===\n\t\t\t\t'Object'\n\t\t);\n\t} catch {\n\t\t// A `getPrototypeOf` trap that throws, or a revoked Proxy. Reading it as\n\t\t// a failure is the safe answer: it is recorded either way, and nothing\n\t\t// here is allowed to raise.\n\t\treturn false;\n\t}\n}\n\n/**\n * The line's name and the attributes its type declared. A lazy message that\n * throws still logs: whatever went wrong building the text, the fact that\n * something happened here is the part worth keeping.\n */\nfunction name(input: LogInput): { name: string; attributes: Attributes } {\n\tif (typeof input === 'string') {\n\t\treturn { name: input, attributes: EMPTY_ATTRIBUTES };\n\t}\n\n\tif (isTelemetryEvent(input)) {\n\t\treturn { name: input.name, attributes: input.attributes };\n\t}\n\n\ttry {\n\t\treturn { name: input(), attributes: EMPTY_ATTRIBUTES };\n\t} catch (failure) {\n\t\treturn {\n\t\t\tname: '[message failed to build]',\n\t\t\tattributes: {\n\t\t\t\t'telemetry.message.invalid': errorInfo(failure, false).type,\n\t\t\t},\n\t\t};\n\t}\n}\n",
19
+ "import {\n\ttype Attributes,\n\ttype AttributeValue,\n\tattributesOf,\n\tcoerceAttribute,\n\tmergeAttributes,\n} from '../attributes/attributes';\nimport { isTelemetryEvent, type TelemetryEvent } from '../logger/event';\nimport { errorInfo, isAbort } from '../model/error';\nimport type {\n\tErrorInfo,\n\tSpanEvent,\n\tSpanKind,\n\tSpanRecord,\n\tSpanStatus,\n} from '../model/signal';\nimport {\n\trenderTraceparent,\n\ttype SpanContext,\n\ttype SpanId,\n\ttype TraceId,\n} from '../trace/ids';\n\n/** The open span, from inside it. Everything here is synchronous. */\nexport interface SpanScope {\n\treadonly context: SpanContext;\n\treadonly traceId: TraceId;\n\treadonly spanId: SpanId;\n\t/** Writable: a server span is named after its route, which routing knows last. */\n\tname: string;\n\t/** Writable, for work that failed without throwing. An exception overrides it. */\n\tstatus: SpanStatus;\n\t/**\n\t * Record a failure the span will not see thrown.\n\t *\n\t * A block that throws is recorded without this. It exists for the frameworks\n\t * that **catch** — Hono turns a handler's exception into a 500 and hands the\n\t * middleware a normal return with the failure on the side — where the only\n\t * thing that knows a request failed is the framework's own field. Without\n\t * it, that span carries a status and no `exception.type`, which is the one\n\t * thing a trace is read for.\n\t *\n\t * **The first failure wins**, and stays won: a framework that catches and\n\t * then rethrows its own wrapper cannot replace the one nearest the cause.\n\t * The cost is that an early `fail()` for something the block went on to\n\t * recover from hides a later, unrelated exception — so call it for the\n\t * failure the span is about, not for every one it sees.\n\t */\n\tfail(failure: unknown): void;\n\t/** The header an outgoing call should carry to continue this trace. */\n\ttraceparent(): string;\n\tattribute(name: string, value: unknown): void;\n\tattributes(record: Readonly<Record<string, unknown>>): void;\n\tevent(name: string, attributes?: Readonly<Record<string, unknown>>): void;\n\tevent(event: TelemetryEvent): void;\n}\n\n/**\n * The open span.\n *\n * Every method is synchronous and none of them can throw: they are called from\n * application code that is already in trouble, and a span that raised would\n * replace the failure it was opened to record.\n */\nexport class Span implements SpanScope {\n\tname: string;\n\tstatus: SpanStatus = 'ok';\n\treadonly context: SpanContext;\n\n\tprivate readonly kind: SpanKind;\n\tprivate readonly stackTraces: boolean;\n\tprivate readonly own: Record<string, AttributeValue> = {};\n\tprivate readonly happened: SpanEvent[] = [];\n\tprivate error: ErrorInfo | undefined;\n\n\tconstructor(\n\t\tcontext: SpanContext,\n\t\tname: string,\n\t\tkind: SpanKind,\n\t\tstackTraces = true,\n\t) {\n\t\tthis.context = context;\n\t\tthis.name = name;\n\t\tthis.kind = kind;\n\t\tthis.stackTraces = stackTraces;\n\t}\n\n\tget traceId(): TraceId {\n\t\treturn this.context.traceId;\n\t}\n\n\tget spanId(): SpanId {\n\t\treturn this.context.spanId;\n\t}\n\n\ttraceparent(): string {\n\t\treturn renderTraceparent(this.context);\n\t}\n\n\tattribute(name: string, value: unknown): void {\n\t\tthis.own[name] = coerceAttribute(value);\n\t}\n\n\tattributes(record: Readonly<Record<string, unknown>>): void {\n\t\tObject.assign(this.own, attributesOf(record));\n\t}\n\n\tevent(\n\t\tinput: string | TelemetryEvent,\n\t\tattributes?: Readonly<Record<string, unknown>>,\n\t): void {\n\t\tconst declared = isTelemetryEvent(input);\n\t\tthis.happened.push({\n\t\t\tname: declared ? input.name : input,\n\t\t\tat: Date.now(),\n\t\t\tattributes: declared ? input.attributes : attributesOf(attributes),\n\t\t});\n\t}\n\n\tfail(failure: unknown): void {\n\t\t// The first failure is the one nearest the cause; a framework that\n\t\t// catches and then rethrows must not overwrite it with its own wrapper.\n\t\tif (this.error !== undefined) return;\n\n\t\tconst cancelled = isAbort(failure);\n\t\tthis.status = cancelled ? 'cancelled' : 'error';\n\t\tthis.error = errorInfo(failure, !cancelled && this.stackTraces);\n\t}\n\n\t/**\n\t * The record that is emitted. Both collections are **copied**: a scope that\n\t * outlives its block — held by a callback, or by a caller that kept it —\n\t * would otherwise mutate a record already sitting in the pipeline buffer.\n\t * The attributes case is the easy one to miss, because `mergeAttributes`\n\t * returns one side unchanged when the other is empty.\n\t */\n\trecord(\n\t\tstartedAt: number,\n\t\tendedAt: number,\n\t\tparent: SpanId | undefined,\n\t\tinherited: Attributes,\n\t): SpanRecord {\n\t\treturn {\n\t\t\ttype: 'span',\n\t\t\tname: this.name,\n\t\t\tcontext: this.context,\n\t\t\t...(parent === undefined ? {} : { parent }),\n\t\t\tkind: this.kind,\n\t\t\tstartedAt,\n\t\t\tendedAt,\n\t\t\tstatus: this.status,\n\t\t\tattributes: { ...mergeAttributes(inherited, this.own) },\n\t\t\tevents: [...this.happened],\n\t\t\t...(this.error === undefined ? {} : { error: this.error }),\n\t\t};\n\t}\n}\n",
20
+ "import {\n\tattributesOf,\n\tEMPTY_ATTRIBUTES,\n\tmergeAttributes,\n} from '../attributes/attributes';\nimport { currentContext, runWithContext } from '../context/current';\nimport type { SpanKind } from '../model/signal';\nimport { installedTelemetry, type Telemetry } from '../telemetry/telemetry';\nimport {\n\tDETACHED_SPAN_CONTEXT,\n\tparseTraceparent,\n\trandomSpanId,\n\trandomTraceId,\n\ttype SpanContext,\n\ttype TraceId,\n} from '../trace/ids';\nimport { Span, type SpanScope } from './scope';\n\nexport interface SpanOptions {\n\t/** Inherited by every log and span inside this one. */\n\treadonly attributes?: Readonly<Record<string, unknown>>;\n\treadonly kind?: SpanKind;\n}\n\nexport type SpanBlock<T> = (scope: SpanScope) => T | Promise<T>;\n\nexport function span<T>(name: string, block: SpanBlock<T>): Promise<T>;\nexport function span<T>(\n\tname: string,\n\toptions: SpanOptions,\n\tblock: SpanBlock<T>,\n): Promise<T>;\n\n/**\n * ```ts\n * await span('charge', { attributes: { orderId } }, async (scope) => {\n * scope.event('gateway.called');\n * await payments.charge(card);\n * });\n * ```\n *\n * The block runs whether or not a telemetry is installed: a library that traces\n * must work inside an application that has never heard of this one. With none,\n * the scope carries a detached context and nothing is emitted.\n *\n * **It never swallows.** A failure marks the span and is rethrown, exactly as\n * it arrived; a span observes, it does not handle.\n */\nexport function span<T>(\n\tname: string,\n\toptionsOrBlock: SpanOptions | SpanBlock<T>,\n\tmaybeBlock?: SpanBlock<T>,\n): Promise<T> {\n\tconst [options, block] = read(optionsOrBlock, maybeBlock);\n\treturn open(name, options, block, undefined, 'internal');\n}\n\nexport function continuing<T>(\n\ttraceparent: string | null | undefined,\n\tname: string,\n\tblock: SpanBlock<T>,\n): Promise<T>;\nexport function continuing<T>(\n\ttraceparent: string | null | undefined,\n\tname: string,\n\toptions: SpanOptions,\n\tblock: SpanBlock<T>,\n): Promise<T>;\n\n/**\n * The same, continuing a trace an inbound `traceparent` started.\n *\n * An unusable header is not an error: it starts a fresh trace, exactly as\n * `span` would. That matters because the header comes from a stranger.\n */\nexport function continuing<T>(\n\ttraceparent: string | null | undefined,\n\tname: string,\n\toptionsOrBlock: SpanOptions | SpanBlock<T>,\n\tmaybeBlock?: SpanBlock<T>,\n): Promise<T> {\n\tconst [options, block] = read(optionsOrBlock, maybeBlock);\n\tconst remote = parseTraceparent(traceparent) ?? undefined;\n\treturn open(name, options, block, remote, 'server');\n}\n\nasync function open<T>(\n\tname: string,\n\toptions: SpanOptions,\n\tblock: SpanBlock<T>,\n\tremote: SpanContext | undefined,\n\tfallbackKind: SpanKind,\n): Promise<T> {\n\tconst parent = currentContext();\n\tconst telemetry = parent?.telemetry ?? installedTelemetry();\n\tconst kind = options.kind ?? fallbackKind;\n\n\tif (telemetry === undefined) {\n\t\treturn block(new Span(DETACHED_SPAN_CONTEXT, name, kind));\n\t}\n\n\t// A remote parent wins over an ambient one: the caller's trace is the trace.\n\tconst parentSpan = remote ?? parent?.span;\n\tconst traceId = parentSpan?.traceId ?? randomTraceId();\n\tconst context: SpanContext = {\n\t\ttraceId,\n\t\tspanId: randomSpanId(),\n\t\t// Asked once, by the root. Below one, the answer is inherited, which is\n\t\t// what keeps a trace whole instead of missing its middle.\n\t\tsampled: parentSpan?.sampled ?? decide(telemetry, traceId),\n\t\tremote: false,\n\t};\n\n\tconst inherited = mergeAttributes(\n\t\tparent?.attributes ?? EMPTY_ATTRIBUTES,\n\t\tattributesOf(options.attributes),\n\t);\n\tconst scope = new Span(context, name, kind, telemetry.stackTraces);\n\tconst startedAt = Date.now();\n\n\ttry {\n\t\treturn await runWithContext(\n\t\t\t{ telemetry, span: context, attributes: inherited },\n\t\t\t() => block(scope),\n\t\t);\n\t} catch (failure) {\n\t\t// Recording must never become the reason the caller's failure is lost,\n\t\t// so nothing in here may raise in its place.\n\t\ttry {\n\t\t\tscope.fail(failure);\n\t\t} catch {\n\t\t\tscope.status = 'error';\n\t\t}\n\t\tthrow failure;\n\t} finally {\n\t\tif (context.sampled) {\n\t\t\ttelemetry.emit(\n\t\t\t\tscope.record(startedAt, Date.now(), parentSpan?.spanId, inherited),\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction read<T>(\n\toptionsOrBlock: SpanOptions | SpanBlock<T>,\n\tmaybeBlock: SpanBlock<T> | undefined,\n): [SpanOptions, SpanBlock<T>] {\n\treturn typeof optionsOrBlock === 'function'\n\t\t? [{}, optionsOrBlock]\n\t\t: [optionsOrBlock, maybeBlock as SpanBlock<T>];\n}\n\n/**\n * A sampler is written by whoever uses this library, so it can throw. Opening a\n * span is not allowed to fail because of it: an unsampled trace loses a\n * dashboard, a thrown sampler loses a request.\n */\nfunction decide(telemetry: Telemetry, traceId: TraceId): boolean {\n\ttry {\n\t\treturn telemetry.sampler.sample(traceId);\n\t} catch {\n\t\treturn false;\n\t}\n}\n"
9
21
  ],
10
- "mappings": ";AAgBO,IAAM,mBAA+B,OAAO,OAAO,CAAC,CAAC;AAcrD,SAAS,eAAe,CAAC,OAAgC;AAAA,EAC/D,IAAI,UAAU,QAAQ,UAAU;AAAA,IAAW,OAAO;AAAA,EAElD,QAAQ,OAAO;AAAA,SACT;AAAA,SACA;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ,OAAO,KAAK;AAAA,SAChD;AAAA,MACJ,OAAO,OAAO,KAAK;AAAA,SACf;AAAA,SACA;AAAA,MACJ,OAAO;AAAA;AAAA,EAGT,IAAI,iBAAiB,MAAM;AAAA,IAC1B,MAAM,KAAK,MAAM,QAAQ;AAAA,IACzB,OAAO,OAAO,MAAM,EAAE,IAAI,OAAO,KAAK,IAAI,MAAM,YAAY;AAAA,EAC7D;AAAA,EAEA,IAAI,MAAM,QAAQ,KAAK;AAAA,IAAG,OAAO,MAAM,IAAI,YAAY;AAAA,EAEvD,OAAO,OAAO,KAAK;AAAA;AAQb,SAAS,YAAY,CAC3B,OACa;AAAA,EACb,IAAI,UAAU;AAAA,IAAW,OAAO;AAAA,EAEhC,MAAM,aAA6C,CAAC;AAAA,EACpD,IAAI,MAAM;AAAA,EAEV,WAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AAAA,IACrC,MAAM,QAAQ,MAAM;AAAA,IACpB,IAAI,UAAU;AAAA,MAAW;AAAA,IACzB,WAAW,OAAO,gBAAgB,KAAK;AAAA,IACvC,MAAM;AAAA,EACP;AAAA,EAEA,OAAO,MAAM,aAAa;AAAA;AAIpB,SAAS,eAAe,CAC9B,MACA,OACa;AAAA,EACb,IAAI,SAAS;AAAA,IAAO,OAAO;AAAA,EAC3B,IAAI,Q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@
1
+ import { type Attributes } from '../attributes/attributes';
2
+ import type { InferInput, StandardSchemaV1 } from './standard-schema';
3
+ /** A named thing that happened, with the fields its type declares. */
4
+ export interface TelemetryEvent {
5
+ readonly name: string;
6
+ readonly attributes: Attributes;
7
+ /** True when the schema refused the input and the fields were read as-is. */
8
+ readonly invalid?: boolean;
9
+ }
10
+ /** The marker an invalid event carries, so it can be found and fixed. */
11
+ export declare const INVALID_EVENT_ATTRIBUTE = "telemetry.event.invalid";
12
+ export declare function event(name: string): (input?: Readonly<Record<string, unknown>>) => TelemetryEvent;
13
+ export declare function event<Schema extends StandardSchemaV1>(name: string, schema: Schema): (input: InferInput<Schema>) => TelemetryEvent;
14
+ export declare function isTelemetryEvent(value: unknown): value is TelemetryEvent;
15
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/logger/event.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAGf,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,wBAAgB,KAAK,CACpB,IAAI,EAAE,MAAM,GACV,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,cAAc,CAAC;AAEjE,wBAAgB,KAAK,CAAC,MAAM,SAAS,gBAAgB,EACpD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACZ,CAAC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,cAAc,CAAC;AAsDjD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAOxE"}
@@ -0,0 +1,46 @@
1
+ import { type Severity } from '../model/signal';
2
+ import { type TelemetryEvent } from './event';
3
+ type Fields = Readonly<Record<string, unknown>>;
4
+ /** A message, a declared event, or a message that is only built if it is wanted. */
5
+ export type LogInput = string | TelemetryEvent | (() => string);
6
+ /** A message or a declared event. The lazy form is for `debug` and `info` only. */
7
+ export type Reported = string | TelemetryEvent;
8
+ /**
9
+ * Writing a log never waits and never fails.
10
+ *
11
+ * Every method here is synchronous and total. With no telemetry installed the
12
+ * line is dropped in silence — a library that logs must work inside an
13
+ * application that has never heard of this one. Below the severity floor
14
+ * nothing is built at all, which is what makes the lazy form worth having.
15
+ */
16
+ export interface Logger {
17
+ /** Whether anything would come of a log at this level, right here. */
18
+ enabled(severity: Severity): boolean;
19
+ debug(input: LogInput, attributes?: Fields): void;
20
+ info(input: LogInput, attributes?: Fields): void;
21
+ warn(input: Reported, attributes?: Fields): void;
22
+ warn(input: Reported, failure: unknown, attributes?: Fields): void;
23
+ error(input: Reported, attributes?: Fields): void;
24
+ error(input: Reported, failure: unknown, attributes?: Fields): void;
25
+ }
26
+ /**
27
+ * ```ts
28
+ * const log = createLogger('CheckoutService');
29
+ *
30
+ * log.info(Charged({ orderId, amount })); // a declared event
31
+ * log.warn('charge refused', { orderId, code }); // ad hoc, for what has no type yet
32
+ * log.debug(() => `state: ${expensive()}`); // built only if debug is on
33
+ * log.error('charge failed', failure, { orderId });
34
+ * ```
35
+ *
36
+ * `source` is the logger's name — a class, a module, whatever groups these
37
+ * lines. It becomes the instrumentation scope an OTLP backend shows.
38
+ *
39
+ * The telemetry is resolved **at each call**, scope first and installed second.
40
+ * That is what lets two suites in one process each collect their own signals,
41
+ * and it is why a logger can be built at module scope before anything is
42
+ * installed.
43
+ */
44
+ export declare function createLogger(source: string):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AgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgDnD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * [Standard Schema](https://standardschema.dev), the part `event` calls. Zod 4,
3
+ * Valibot and ArkType schemas all carry it, so this package imports none of
4
+ * them: it reads their `~standard`. The same shape `@nxgt/httpyz` declares, and
5
+ * for the same reason.
6
+ */
7
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
8
+ readonly '~standard': {
9
+ readonly version: 1;
10
+ readonly vendor: string;
11
+ readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
12
+ readonly types?: {
13
+ readonly input: Input;
14
+ readonly output: Output;
15
+ } | undefined;
16
+ };
17
+ }
18
+ export type StandardResult<Output> = {
19
+ readonly value: Output;
20
+ readonly issues?: undefined;
21
+ } | {
22
+ readonly issues: readonly StandardIssue[];
23
+ };
24
+ export interface StandardIssue {
25
+ readonly message: string;
26
+ readonly path?: readonly (PropertyKey | {
27
+ readonly key: PropertyKey;
28
+ })[] | undefined;
29
+ }
30
+ /** What a schema accepts. */
31
+ export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
32
+ //# sourceMappingURL=standard-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../../src/logger/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;IAChE,QAAQ,CAAC,WAAW,EAAE;QACrB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,CAClB,KAAK,EAAE,OAAO,KACV,cAAc,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9D,QAAQ,CAAC,KAAK,CAAC,EACZ;YAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;YAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAClD,SAAS,CAAC;KACb,CAAC;CACF;AAED,MAAM,MAAM,cAAc,CAAC,MAAM,IAC9B;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,GACvD;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EACX,SAAS,CAAC,WAAW,GAAG;QAAE,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;KAAE,CAAC,EAAE,GACxD,SAAS,CAAC;CACb;AAED,6BAA6B;AAC7B,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACpE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC5B,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { ErrorInfo } from './signal';
2
+ /**
3
+ * A thrown value, flattened onto the wire.
4
+ *
5
+ * **Nothing here can throw.** `throw` accepts anything — a string, a Proxy, an
6
+ * `Error` subclass with a getter that raises, an object from another realm —
7
+ * and this runs inside a `catch`, where a second failure would replace the
8
+ * application's first one and lose it. Every property read is guarded, and a
9
+ * value it cannot read at all still produces a record.
10
+ */
11
+ export declare function errorInfo(failure: unknown, stackTraces?: boolean): ErrorInfo;
12
+ /**
13
+ * Whether a failure is work that was called off rather than work that broke.
14
+ *
15
+ * `cancelled` is a status of its own so that a shutdown and a timeout do not
16
+ * read as failures — a dashboard that counts them as such is a dashboard nobody
17
+ * trusts. `AbortError` is what an `AbortSignal` rejects with, and `TimeoutError`
18
+ * is what `AbortSignal.timeout` rejects with.
19
+ */
20
+ export declare function isAbort(failure: unknown): boolean;
21
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/model/error.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,UAAO,GAAG,SAAS,CAMzE;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAIjD"}
@@ -0,0 +1,71 @@
1
+ import { type Attributes } from '../attributes/attributes';
2
+ import { type TelemetryEvent } from '../logger/event';
3
+ import type { SpanKind, SpanRecord, SpanStatus } from '../model/signal';
4
+ import { type SpanContext, type SpanId, type TraceId } from '../trace/ids';
5
+ /** The open span, from inside it. Everything here is synchronous. */
6
+ export interface SpanScope {
7
+ readonly context: SpanContext;
8
+ readonly traceId: TraceId;
9
+ readonly spanId: SpanId;
10
+ /** Writable: a server span is named after its route, which routing knows last. */
11
+ name: string;
12
+ /** Writable, for work that failed without throwing. An exception overrides it. */
13
+ status: SpanStatus;
14
+ /**
15
+ * Record a failure the span will not see thrown.
16
+ *
17
+ * A block that throws is recorded without this. It exists for the frameworks
18
+ * that **catch** — Hono turns a handler's exception into a 500 and hands the
19
+ * middleware a normal return with the failure on the side — where the only
20
+ * thing that knows a request failed is the framework's own field. Without
21
+ * it, that span carries a status and no `exception.type`, which is the one
22
+ * thing a trace is read for.
23
+ *
24
+ * **The first failure wins**, and stays won: a framework that catches and
25
+ * then rethrows its own wrapper cannot replace the one nearest the cause.
26
+ * The cost is that an early `fail()` for something the block went on to
27
+ * recover from hides a later, unrelated exception — so call it for the
28
+ * failure the span is about, not for every one it sees.
29
+ */
30
+ fail(failure: unknown): void;
31
+ /** The header an outgoing call should carry to continue this trace. */
32
+ traceparent(): string;
33
+ attribute(name: string, value: unknown): void;
34
+ attributes(record: Readonly<Record<string, unknown>>): void;
35
+ event(name: string, attributes?: Readonly<Record<string, unknown>>): void;
36
+ event(event: TelemetryEvent): void;
37
+ }
38
+ /**
39
+ * The open span.
40
+ *
41
+ * Every method is synchronous and none of them can throw: they are called from
42
+ * application code that is already in trouble, and a span that raised would
43
+ * replace the failure it was opened to record.
44
+ */
45
+ export declare class Span implements SpanScope {
46
+ name: string;
47
+ status: SpanStatus;
48
+ readonly context: SpanContext;
49
+ private readonly kind;
50
+ private readonly stackTraces;
51
+ private readonly own;
52
+ private readonly happened;
53
+ private error;
54
+ constructor(context: SpanContext, name: string, kind: SpanKind, stackTraces?: boolean);
55
+ get traceId(): TraceId;
56
+ get spanId(): SpanId;
57
+ traceparent(): string;
58
+ attribute(name: string, value: unknown): void;
59
+ attributes(record: Readonly<Record<string, unknown>>): void;
60
+ event(input: string | TelemetryEvent, attributes?: Readonly<Record<string, unknown>>): void;
61
+ fail(failure: unknown): void;
62
+ /**
63
+ * The record that is emitted. Both collections are **copied**: a scope that
64
+ * outlives its block — held by a callback, or by a caller that kept it —
65
+ * would otherwise mutate a record already sitting in the pipeline buffer.
66
+ * The attributes case is the easy one to miss, because `mergeAttributes`
67
+ * returns one side unchanged when the other is empty.
68
+ */
69
+ record(startedAt: number, endedAt: number, parent: SpanId | undefined, inherited: Attributes): SpanRecord;
70
+ }
71
+ //# sourceMappingURL=scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/span/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAKf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,KAAK,EAGX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEN,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK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AQ,EACd,WAAW,UAAO;IAQnB,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,WAAW,IAAI,MAAM;IAIrB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAI7C,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI;IAI3D,KAAK,CACJ,KAAK,EAAE,MAAM,GAAG,cAAc,EAC9B,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC5C,IAAI;IASP,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAU5B;;;;;;OAMG;IACH,MAAM,CACL,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,SAAS,EAAE,UAAU,GACnB,UAAU;CAeb"}
@@ -0,0 +1,13 @@
1
+ import type { SpanKind } from '../model/signal';
2
+ import { type SpanScope } from './scope';
3
+ export interface SpanOptions {
4
+ /** Inherited by every log and span inside this one. */
5
+ readonly attributes?: Readonly<Record<string, unknown>>;
6
+ readonly kind?: SpanKind;
7
+ }
8
+ export type SpanBlock<T> = (scope: SpanScope) => T | Promise<T>;
9
+ export declare function span<T>(name: string, block: SpanBlock<T>): Promise<T>;
10
+ export declare function span<T>(name: string, options: SpanOptions, block: SpanBlock<T>): Promise<T>;
11
+ export declare function continuing<T>(traceparent: string | null | undefined, name: string, block: SpanBlock<T>): Promise<T>;
12
+ export declare function continuing<T>(traceparent: string | null | undefined, name: string, options: SpanOptions, block: SpanBlock<T>): Promise<T>;
13
+ //# sourceMappingURL=span.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../src/span/span.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE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