@zuke/otel

← API reference

`@zuke/otel` — an OpenTelemetry (OTLP/HTTP **JSON**) export plugin for Zuke

Symbols

# otel function
function otel(configure?: Configure<OtelSettings>): Plugin

Create the OpenTelemetry export plugin. Register it on a run and every run/target transition is exported as OTLP/HTTP JSON:

import { run } from "jsr:@zuke/core";
import { otel } from "jsr:@zuke/otel";

await run(MyBuild, {
  plugins: [otel((s) => s.endpoint("http://localhost:4318").serviceName("ci"))],
});

With no argument it reads the standard OTEL_EXPORTER_OTLP_ENDPOINT / OTEL_SERVICE_NAME / OTEL_EXPORTER_OTLP_HEADERS environment variables. If no endpoint is configured by either route the plugin is inert, so it is safe to register unconditionally. Telemetry needs a state store (the plugin's records come from durable run state); a store-less build exports nothing.

# OtelSettings class
class OtelSettings

Configuration for the OTLP exporter, set through a lambda passed to "./plugin.ts".otel. Every setter returns this so calls chain, and each value falls back to the matching OTEL_* environment variable when left unset (see resolveOtel).

MemberSignatureDoc
endpoint endpoint(url: string): this Set the base OTLP/HTTP endpoint; /v1/traces and /v1/metrics are appended.
tracesEndpoint tracesEndpoint(url: string): this Set a full endpoint URL for the trace signal (no path is appended).
metricsEndpoint metricsEndpoint(url: string): this Set a full endpoint URL for the metric signal (no path is appended).
serviceName serviceName(name: string): this Set the service.name reported to the collector.
header header(name: string, value: string): this Add one HTTP header to every export request.
headers headers(map: Record<string, string>): this Merge a map of HTTP headers into the export requests.
resourceAttribute resourceAttribute(name: string, value: string): this Add one OTLP resource attribute.
resourceAttributes resourceAttributes(map: Record<string, string>): this Merge a map of OTLP resource attributes.
timeout timeout(duration: string): this Set the per-request timeout (a duration string like "5s").
endpoint_? endpoint_?: string The base OTLP/HTTP endpoint (e.g. http://localhost:4318).
tracesEndpoint_? tracesEndpoint_?: string A full endpoint for the trace signal, overriding endpoint_ + /v1/traces.
metricsEndpoint_? metricsEndpoint_?: string A full endpoint for the metric signal, overriding endpoint_ + /v1/metrics.
serviceName_? serviceName_?: string The service.name resource attribute.
headers_ headers_: Record<string, string> Extra HTTP headers sent on every export (e.g. an auth token).
resourceAttributes_ resourceAttributes_: Record<string, string> Extra OTLP resource attributes (e.g. deployment.environment).
timeoutMs_ timeoutMs_: number Per-request timeout in milliseconds (default 10s).