addLangfuseExporter

fun OpenTelemetryConfig.addLangfuseExporter(langfuseUrl: String? = null, langfusePublicKey: String? = null, langfuseSecretKey: String? = null, timeout: Duration? = null, traceAttributes: List<CustomAttribute>? = null)(source)

Configures a span exporter that sends data to Langfuse and installs the Langfuse SpanAdapter that reshapes spans to the Langfuse-recommended attribute layout.

Uses the Kotlin Multiplatform OTLP/JSON exporter - works on every target supported by the OpenTelemetry feature. Authenticates via HTTP Basic with LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY (passed in or read from environment variables).

Registered via addSpanExporter, which wraps the exporter in a batch span processor - the cloud HTTP round-trip happens on a worker thread instead of blocking the agent on each span end.

For test or non-cloud setups that need only the span transformations, see addLangfuseSpanAdapter.

Parameters

langfuseUrl

base Langfuse URL;

langfusePublicKey

Langfuse public key. Defaults to LANGFUSE_PUBLIC_KEY env var;

langfuseSecretKey

Langfuse secret key. Defaults to LANGFUSE_SECRET_KEY env var;

timeout

request timeout (10 seconds by default);

traceAttributes

list of trace-level Langfuse attributes (see https://langfuse.com/integrations/native/opentelemetry#propagating-attributes).