/** * OTLP over gRPC, with no SDK and no gRPC library: the trace service's one call, `Export`, framed * by hand over Node's own HTTP/2 client. */ import http2 from 'node:http2'; import { type OtlpSpan, OtlpTraceExporter, type OtlpTraceExporterOptions } from './otlp.js'; /** Options for `OtlpGrpcTraceExporter`. */ export interface OtlpGrpcTraceExporterOptions extends Omit { /** * The collector's OTLP gRPC address, such as `http://localhost:4317` for a connection without TLS * or `https://collector.example.com:4317` for one with it. */ endpoint: string; /** gRPC metadata on every call, such as an API key a hosted backend wants. Names are lowercased. */ headers?: Record; /** Compresses each batch with gzip. Defaults to true, as collectors accept it. */ gzip?: boolean; /** How long one export may take, sent as the call's deadline. Defaults to 10 seconds. */ timeoutMs?: number; /** * Options for the HTTP/2 connection, such as a `ca`, a client `cert` and `key`, or `servername`, * passed to `http2.connect()`. */ connect?: http2.SecureClientSessionOptions; } /** Thrown when the collector answers an export with a gRPC status other than OK. */ export declare class OtlpGrpcError extends Error { /** The gRPC status code, such as 14 for `UNAVAILABLE`. */ readonly code: number; /** What the collector said. */ readonly details: string; constructor( /** The gRPC status code, such as 14 for `UNAVAILABLE`. */ code: number, /** What the collector said. */ details: string); } /** * Sends finished runs to any OpenTelemetry collector as OTLP over gRPC, port 4317, in OTLP's * protobuf encoding: the same spans, batching, and GenAI attributes as `OtlpTraceExporter`, for a * collector or backend that takes gRPC only. Node.js only, since it speaks HTTP/2 through * `node:http2`. * * One connection is kept and reused, opened again when it drops; it never keeps the process alive * while no export is in flight. A call the collector refuses rejects `send()` with an * `OtlpGrpcError`, so `spoolingExporter()` keeps the batch; on its own, the batch goes to `onError`. * `close()` sends what is waiting and closes the connection. */ export declare class OtlpGrpcTraceExporter extends OtlpTraceExporter { private readonly grpc; private session; private inFlight; constructor(grpc: OtlpGrpcTraceExporterOptions); /** Sends what is waiting, then closes the connection. */ close(): Promise; protected post(spans: OtlpSpan[]): Promise; /** One call, holding the connection open while it is in flight. */ private attempt; private connection; private call; }