import type { MetricsSink } from '../types/observability.js'; /** * V2-A: OTLP/JSON metrics push exporter. * * Periodically POSTs `MetricsSink.snapshot()` to an OTLP HTTP receiver * (the OpenTelemetry Collector, vendor agents like Honeycomb, Datadog, * Grafana Cloud, etc.). The wire format is OTLP/JSON v1.0 — covered by * the spec at github.com/open-telemetry/opentelemetry-proto. * * Why no `@opentelemetry/*` dep: the core graph is intentionally * dependency-free. The JSON shape is well-defined and stable; bringing * in the official SDK would add ~3MB and pin us to its release cadence. * Operators who need the OTLP gRPC transport or vendor-specific quirks * can wrap an `@opentelemetry/exporter-metrics-otlp-grpc` in a custom * `MetricsSink` instead — the seam exists. */ export interface OtlpMetricsExporterOptions { /** Source of metric data. The exporter reads `snapshot()` per interval. */ sink: MetricsSink; /** * OTLP HTTP endpoint base URL. Path `/v1/metrics` is appended unless * the URL already ends with `/v1/metrics` (idempotent). * Example: `http://otel-collector:4318` or `https://otlp.example.com`. */ endpoint: string; /** Push interval in milliseconds. Defaults to 30s (Prometheus default). */ intervalMs?: number | undefined; /** Optional bearer token / API key (sent as `Authorization`). */ authorization?: string | undefined; /** Extra request headers (vendor-specific keys go here). */ headers?: Record; /** Resource attributes attached to every export. Defaults: `service.name=wrongstack`. */ resourceAttributes?: Record; /** Instrumentation scope. Default: `wrongstack`. */ scopeName?: string | undefined; /** Per-request timeout. Defaults to 10s. */ timeoutMs?: number | undefined; /** Override fetch (for tests). Defaults to global `fetch`. */ fetchImpl?: typeof globalThis.fetch | undefined; /** Called when a push fails. Defaults to silent (telemetry must never crash the host). */ onError?: ((err: unknown) => void) | undefined; } export interface OtlpMetricsExporterHandle { /** Push immediately (in addition to the scheduled interval). */ flush(): Promise; /** Stop the timer, attempt a final flush, then resolve. */ stop(): Promise; } interface OtlpAttribute { key: string; value: { stringValue: string; }; } interface OtlpDataPoint { attributes: OtlpAttribute[]; timeUnixNano: string; asDouble?: number | undefined; asInt?: string | undefined; count?: string | undefined; sum?: number | undefined; quantileValues?: { quantile: number | undefined; value: number; }[]; } interface OtlpMetric { name: string; description?: string | undefined; unit?: string | undefined; sum?: { dataPoints: OtlpDataPoint[] | undefined; aggregationTemporality: 2; isMonotonic: true; }; gauge?: { dataPoints: OtlpDataPoint[] | undefined; }; summary?: { dataPoints: OtlpDataPoint[] | undefined; }; } interface OtlpExportRequest { resourceMetrics: { resource: { attributes: OtlpAttribute[]; }; scopeMetrics: { scope: { name: string; version?: string | undefined; }; metrics: OtlpMetric[]; }[]; }[]; } /** * Build the OTLP/JSON export body from a sink snapshot. Exported for tests * and for callers that want to ship via their own transport. */ export declare function buildOtlpMetricsRequest(sink: MetricsSink, opts?: { resourceAttributes?: Record; scopeName?: string | undefined; }): OtlpExportRequest; /** * Start pushing metrics to an OTLP HTTP receiver. Returns a handle with * `flush()` and `stop()`. */ export declare function startOtlpMetricsExporter(opts: OtlpMetricsExporterOptions): OtlpMetricsExporterHandle; export {}; //# sourceMappingURL=otlp-metrics.d.ts.map