Askr documentation
Generated API snapshot

@askrjs/otel

Exports from the declarations published in @askrjs/otel. Signatures reflect the published artifact.

Exports

This entrypoint publishes 7 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

createTelemetrytype

createTelemetry: (options?: TelemetryOptions) => Telemetry

Creates a function-first bridge to the application's installed OpenTelemetry provider. This package never installs an SDK, processor, backend, or exporter.

Telemetrytype

Telemetry: any

Function-first bridge to the application's installed OpenTelemetry provider. Every method wraps a unit of work in a span (or emits a log line) and never throws on account of tracing/logging failures — application behavior is always isolated from observability failures.

span
Wraps `work` in a span for the given `operation`, recording `fields` as attributes.
request
Convenience wrapper for {@link Telemetry.span} with operation `"askr.request"`.
routeMatch
Convenience wrapper for {@link Telemetry.span} with operation `"askr.route.match"`.
loader
Convenience wrapper for {@link Telemetry.span} with operation `"askr.loader"`.
action
Convenience wrapper for {@link Telemetry.span} with operation `"askr.action"`.
apiOperation
Convenience wrapper for {@link Telemetry.span} with operation `"askr.api.operation"`.
queryPrefetch
Convenience wrapper for {@link Telemetry.span} with operation `"askr.query.prefetch"`.
ssrRender
Convenience wrapper for {@link Telemetry.span} with operation `"askr.ssr.render"`.
viteDocument
Convenience wrapper for {@link Telemetry.span} with operation `"askr.vite.document"`.
log
Emits a single sanitized log line without opening a span.
extract
Extracts a trace {@link Context} from a carrier (e.g. incoming request headers) using `getter`.
inject
Injects the active (or given) {@link Context} into `carrier` using `setter`, returning the carrier.
withContext
Runs `work` with `value` as the active OpenTelemetry context.
traceId
Returns the trace ID of the currently active span, if any and if valid.

TelemetryFieldstype

TelemetryFields: any

Structured fields attached to a span or log line. Only these known keys are ever sanitized and forwarded; unknown keys on a passed-in object are dropped.

requestId
requestId?: string;
traceId
traceId?: string;
route
route?: string;
action
action?: string;
operation
operation?: string;
status
status?: number;
durationMs
durationMs?: number;

TelemetryLeveltype

TelemetryLevel: "debug" | "info" | "warn" | "error"

Severity of a telemetry log line, mirrored from common structured-logging conventions.

TelemetryLoggertype

TelemetryLogger: (level: TelemetryLevel, event: TelemetryOperation, fields: Readonly<TelemetryFields>) => void

Callback invoked with each sanitized telemetry log line.

TelemetryOperationtype

TelemetryOperation: "askr.request" | "askr.route.match" | "askr.loader" | "askr.action" | "askr.api.operation" | "askr.query.prefetch" | "askr.ssr.render" | "askr.vite.document"

The set of Askr lifecycle stages that {@link Telemetry} can wrap with a span.

TelemetryOptionstype

TelemetryOptions: any

Configuration accepted by {@link createTelemetry}.

tracerName
Name passed to `trace.getTracer`. Defaults to `"@askrjs/otel"`.
tracerVersion
Version passed to `trace.getTracer`.
logger
Sink for sanitized log lines. Defaults to a no-op.
now
Clock used for span durations. Defaults to `performance.now`.
maxFieldLength
Maximum length, in characters, retained for any string field. Defaults to 256.
sanitizeField
Per-field hook to redact or transform a field before it is logged or attached to a span; return `undefined` to drop it.
sanitizeException
Exceptions are not exported unless this hook returns a sanitized value.