import type { TransportRecord, HookLogEntry } from '../types/index.js'; import { HttpTransport } from './HttpTransport.js'; /** * Options for {@link OtlpTransport}. * */ export interface OtlpTransportOptions { /** * OTLP/HTTP collector base URL, e.g. `https://collector.example.com:4318`. * The transport POSTs to `/v1/logs`. */ endpoint: string; /** `service.name` resource attribute. Required by OTel spec. */ serviceName: string; /** `service.version` resource attribute. Recommended. */ serviceVersion?: string; /** `deployment.environment` resource attribute (production/staging/dev). */ environment?: string; /** Extra resource attributes merged into the resource block. */ resourceAttributes?: Record; /** * Name of an env var whose value is sent as the `signoz-ingestion-key` * header. The transport reads `process.env[ingestKeyEnvVar]` at * construction time — never from a string literal. If the env var is * unset, the header is silently omitted (OTLP collector uses default * no-auth path). */ ingestKeyEnvVar?: string; /** Extra headers merged in (Authorization, custom X-*). */ headers?: Record; /** Batch size (records per POST). Default 50. */ batchSize?: number; /** Flush interval in ms. */ flushInterval?: number; /** Hard cap on buffered records. Default 10_000. */ maxBufferSize?: number; /** Max retry attempts per batch. Default 3. */ maxRetries?: number; /** Initial backoff in ms. Default 250. */ initialBackoffMs?: number; /** Backoff ceiling in ms. Default 5_000. */ maxBackoffMs?: number; /** Per-fetch timeout in ms. Default 10_000. */ fetchTimeoutMs?: number; /** Hook fired on transport failure (drop, retry exhaustion, ...). */ onError?: (entry: HookLogEntry) => void | Promise; } /** * Shape of the OTLP/HTTP JSON request body. Matches the `LogsData` proto * JSON mapping for `/v1/logs`. See * https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding */ interface OtlpLogsPayload { resourceLogs: Array<{ resource: { attributes: Array<{ key: string; value: { stringValue: string; }; }>; }; scopeLogs: Array<{ scope: { name: string; version: string; }; logRecords: Array; }>; }>; } interface OtlpLogRecord { timeUnixNano: string; observedTimeUnixNano: string; severityNumber: number; severityText: string; body: { stringValue: string; }; attributes?: Array<{ key: string; value: OtlpAttributeValue; }>; traceId?: string; spanId?: string; } type OtlpAttributeValue = { stringValue: string; } | { intValue: number; } | { doubleValue: number; } | { boolValue: boolean; } | { arrayValue: { values: OtlpAttributeValue[]; }; }; /** * OTLP/HTTP transport for SigNoz (or any OTLP-compliant backend). * * Extends {@link HttpTransport} — inherits retry, bounded buffer, status * check, async close, and the on-error hook. Overrides only the payload * shape and the request headers. * * ```ts * logger.addTransport({ * target: new OtlpTransport({ * endpoint: 'https://otelcollector.example.com:4318', * serviceName: 'my-app', * serviceVersion: '1.2.3', * environment: 'production', * ingestKeyEnvVar: 'SIGNOZ_KEY' * }) * }); * ``` * */ export declare class OtlpTransport extends HttpTransport { readonly name = "otlp"; private readonly resource; /** Resolved at construction. Never logged, never written to source. */ private readonly ingestKeyValue; constructor(options: OtlpTransportOptions); /** * Builds the OTLP/HTTP JSON payload from the currently buffered records. * One `resourceLogs` block per batch (matches OTel collector batching * guidance). Exposed for tests + custom transport subclasses. * */ buildPayload(records: TransportRecord[]): OtlpLogsPayload; /** * Serialises a batch into the OTLP/HTTP JSON request body. Overrides * {@link HttpTransport.serializeBody}. * */ protected serializeBody(records: TransportRecord[]): string; /** * Builds request headers. Adds `signoz-ingestion-key` from the value * resolved at construction time (never logged, never written to source). * */ protected buildHeaders(): Record; private toLogRecord; } export {}; //# sourceMappingURL=OtlpTransport.d.ts.map