/** * @absolutejs/telemetry/otlp-http — zero-dependency OTLP-HTTP-JSON * span exporter. Implements the `TracerProvider` interface from * `./index`, so any substrate package taking a `tracerProvider` * option (sync, queue, runtime, etc.) can plug it in directly. * * Scope: * * - Spans are batched in memory and flushed on a schedule (or when * the queue fills). * - Wire format is OTLP/JSON over HTTP (the OTel spec's * standardized HTTP encoding). Most OTLP collectors accept * either Protobuf or JSON; JSON has zero dependencies. * - Head-based ratio sampling — sampled at root, propagated to * every child span in the trace. * * Out of scope (use `@opentelemetry/sdk-node` if you need them): * * - Async context propagation across `await` boundaries. Each call * to `tracer.startSpan(name)` creates a fresh root unless the * caller threads the parent explicitly (`options.links` or by * calling `span.spanContext()` on a parent and using it). * - W3C `traceparent` parsing on inbound HTTP requests. * - OTLP/Protobuf encoding (use the official SDK for that). * - Metric or log exports — this is the span exporter only. * * The trade is real but the audit surface is one repo, the bundle * is small (~10 KB), and the install footprint is zero peer deps. */ import type { TracerProvider } from './index'; export type OtlpExporterOptions = { /** * Full OTLP traces endpoint, e.g. * `http://localhost:4318/v1/traces` for a local collector, * `https://otel.honeycomb.io/v1/traces` for Honeycomb, etc. */ endpoint: string; /** Required — appears on every exported span as `service.name`. */ serviceName: string; /** Optional `service.version` resource attribute. */ serviceVersion?: string; /** Optional additional HTTP headers (auth, tenant routing, etc.). */ headers?: Record; /** Resource attributes merged into the OTLP `resource.attributes`. */ resourceAttributes?: Record; /** * Periodic flush interval. Default 5_000 ms. Spans are also flushed * eagerly when `maxBatchSize` is reached. */ scheduledDelayMs?: number; /** Max spans per HTTP batch. Default 512. */ maxBatchSize?: number; /** * Max spans queued before we start dropping. Default 2048. Drops * are counted in `metrics().droppedDueToQueueLimit`. */ maxQueueSize?: number; /** * Head-based sample ratio in [0, 1]. Default 1.0 (export every * span). Set to e.g. 0.1 to export 10% of traces. Sampled at root; * all children of a sampled trace are also sampled. */ sampleRatio?: number; /** Override `fetch`. Useful for tests + injecting retry/auth. */ fetch?: typeof fetch; /** Override `Date.now()`. Useful for deterministic tests. */ clock?: () => number; /** * Hi-res clock — nanoseconds since epoch as a `bigint`. Default * uses `BigInt(Date.now()) * 1_000_000n + BigInt(process.hrtime.bigint() % 1_000_000n)`, * which gives microsecond-grade precision on most platforms. */ hrClock?: () => bigint; /** * Override the ID generator. Default uses `crypto.getRandomValues`. */ idGenerator?: { generateTraceId: () => string; generateSpanId: () => string; }; /** * Per-export error handler. Default `console.warn`. The exporter * does NOT retry — implement that here if you need it. */ onError?: (error: unknown, batchSize: number) => void; }; export type OtlpProviderMetrics = { /** Spans currently in the in-memory queue. */ queued: number; /** Total spans successfully exported. */ exported: number; /** Total spans dropped because the queue was full. */ droppedDueToQueueLimit: number; /** Total spans not exported because the sampler rejected them. */ notSampled: number; /** Total spans the sampler kept. */ sampled: number; /** Total batches POSTed. */ batches: number; /** Total batches that failed the POST. */ batchErrors: number; }; export type OtlpTracerProvider = TracerProvider & { /** Drain the in-memory queue with one POST. */ flush: () => Promise; /** * Stop scheduling exports, drain the queue, mark the provider * closed. Subsequent `getTracer().startSpan()` calls still build * spans but their `end()` will not enqueue. */ shutdown: () => Promise; /** Operator visibility — cumulative counters since construction. */ metrics: () => OtlpProviderMetrics; }; export declare const createOtlpTracerProvider: (options: OtlpExporterOptions) => OtlpTracerProvider; //# sourceMappingURL=otlpHttp.d.ts.map