OtlpJsonSpanExporter

class OtlpJsonSpanExporter(endpoint: String, headers: Map<String, String> = emptyMap(), timeout: Duration? = null, baseClient: HttpClient? = null) : SpanExporter(source)

Kotlin Multiplatform OTLP/JSON SpanExporter implementation.

Sends spans over HTTP to any OTLP/JSON-compatible receiver (Langfuse, W&B Weave, generic collectors). The wire format follows https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding with Content-Type: application/json and the JSON-encoded ExportTraceServiceRequest.

On non-2xx responses or transport errors, returns OperationResultCode.Failure; the configured span processor (typically BatchSpanProcessor) drops the failed batch.

Note: There is no built-in retry / back-off.

Parameters

endpoint

full OTLP/JSON URL, e.g. https://cloud.langfuse.com/api/public/otel/v1/traces.

headers

extra HTTP headers (typically Authorization);

timeout

request timeout, by default, set to 10 seconds;

baseClient

optional HttpClient. When provided, the exporter uses it as-is and skips the default ContentNegotiation install - the caller must provide a JSON serializer.

Constructors

Link copied to clipboard
constructor(endpoint: String, headers: Map<String, String> = emptyMap(), timeout: Duration? = null, baseClient: HttpClient? = null)

Functions

Link copied to clipboard
open suspend override fun export(telemetry: List<SpanData>): OperationResultCode
Link copied to clipboard
open suspend override fun forceFlush(): OperationResultCode
Link copied to clipboard
open suspend override fun shutdown(): OperationResultCode