OpenTelemetryConfig
Configuration class for the OpenTelemetry integration.
Tracing is backed by the Kotlin Multiplatform OpenTelemetry SDK - the tracing surface defined here (span processors, resource attributes, verbose mode, service info) is available on every target.
Tracing-side integrations (Langfuse, W&B Weave, Datadog) ship as commonMain extensions on top of an OTLP/JSON exporter, so they work on every target. The Kotlin SDK ships no metrics module, so metrics still live behind JVM-only extension functions declared in jvmMain (addMetricExporter, addMetricFilter, meter).
Power users who need full control over the SDK (custom samplers, custom span processors, span limits, etc.) can construct their own OpenTelemetry via createOpenTelemetry and inject it via setSdk - in that case the other configuration setters become inert.
Configuration class for the OpenTelemetry feature, providing integration and export mechanisms for traces, metrics, and other telemetry data. This class abstracts the underlying implementation and offers convenient methods for setup and configuration within the Kotlin Multiplatform SDK.
The class includes constructors, methods, and properties used to manage telemetry exporters, filters, and adapters, as well as Java-friendly API overrides for compatibility with Java callers.
This configuration is designed to work across different platforms and integrates seamlessly with Java SDK.
Note: Some configurations rely on the Java SDK due to limitations in the current Kotlin Multiplatform SDK.
Configuration class for the OpenTelemetry integration.
Tracing is backed by the Kotlin Multiplatform OpenTelemetry SDK - the tracing surface defined here (span processors, resource attributes, verbose mode, service info) is available on every target.
Tracing-side integrations (Langfuse, W&B Weave, Datadog) ship as commonMain extensions on top of an OTLP/JSON exporter, so they work on every target. The Kotlin SDK ships no metrics module, so metrics still live behind JVM-only extension functions declared in jvmMain (addMetricExporter, addMetricFilter, meter).
Power users who need full control over the SDK (custom samplers, custom span processors, span limits, etc.) can construct their own OpenTelemetry via createOpenTelemetry and inject it via setSdk - in that case the other configuration setters become inert.
Constructors
Constructs a new OpenTelemetryConfig with default service information.
Constructs a new OpenTelemetryConfig with default service information.
Constructs a new OpenTelemetryConfig with default service information.
Properties
Indicates whether OpenTelemetry resources should be shut down when the agent closes.
Indicates whether OpenTelemetry resources should be shut down when the agent closes.
Indicates whether OpenTelemetry resources should be shut down when the agent closes.
The service name reported in resource attributes.
The service name reported in resource attributes.
The service name reported in resource attributes.
The service namespace reported in resource attributes, or null if not set.
The service namespace reported in resource attributes, or null if not set.
The service namespace reported in resource attributes, or null if not set.
The service version reported in resource attributes.
The service version reported in resource attributes.
The service version reported in resource attributes.
The Kotlin Multiplatform OpenTelemetry SDK Tracer used by the feature.
The Kotlin Multiplatform OpenTelemetry SDK Tracer used by the feature.
The Kotlin Multiplatform OpenTelemetry SDK Tracer used by the feature.
Functions
Java-friendly entry point for the Datadog integration. Mirrors the commonMain addDatadogExporter but accepts java.time.Duration for timeout so Java callers can pass every parameter - the commonMain overload uses kotlin.time.Duration, whose value-class JVM-name mangling makes the resourceAttributes argument unreachable from Java.
Configure an OpenTelemetry span exporter that sends data to Datadog via direct OTLP intake.
Java-friendly entry point for the Langfuse integration. Mirrors the commonMain addLangfuseExporter but accepts java.time.Duration for timeout so Java callers can pass every parameter - the commonMain overload uses kotlin.time.Duration, whose value-class JVM-name mangling makes the traceAttributes argument unreachable from Java.
Configures a span exporter that sends data to Langfuse and installs the Langfuse SpanAdapter that reshapes spans to the Langfuse-recommended attribute layout.
Installs the Langfuse SpanAdapter without registering the Langfuse cloud exporter. Spans are reshaped to the Langfuse-recommended attribute layout but are emitted only through whatever exporters the caller registers separately.
Registers a Java-SDK MetricExporter driven by a PeriodicMetricReader at meterInterval.
Registers a OTel Java SDK MetricExporter driven by a PeriodicMetricReader at meterInterval.
Registers a filter that restricts the attribute keys retained on a given metric during aggregation.
Adds resource attributes reported alongside every exported span.
Adds resource attributes reported alongside every exported span.
Adds resource attributes reported alongside every exported span.
Installs a SpanAdapter that post-processes every GenAI span. Replaces any previously installed adapter.
Installs a SpanAdapter that post-processes every GenAI span. Replaces any previously installed adapter.
Installs a SpanAdapter that post-processes every GenAI span. Replaces any previously installed adapter.
Registers exporter wrapped in a batchSpanProcessor - the OTel-recommended default for production deployments. Spans are buffered and flushed on a worker so the agent never blocks on network I/O at the span end.
JVM convenience that bridges a Java-SDK SpanExporter to the Kotlin SDK via toOtelKotlinSpanExporter and registers it through addSpanExporter.
Registers exporter wrapped in a batchSpanProcessor - the OTel-recommended default for production deployments. Spans are buffered and flushed on a worker so the agent never blocks on network I/O at the span end.
Registers exporter wrapped in a batchSpanProcessor - the OTel-recommended default for production deployments. Spans are buffered and flushed on a worker so the agent never blocks on network I/O at the span end.
Registers a SpanProcessor produced by a factory invoked inside the SDK's TraceExportConfigDsl scope. Use this when the convenience addSpanExporter (which always wraps in batchSpanProcessor) doesn't fit - e.g., custom batching parameters, custom processor implementations, or a compositeSpanProcessor over several inner processors.
Registers a SpanProcessor produced by a factory invoked inside the SDK's TraceExportConfigDsl scope. Use this when the convenience addSpanExporter (which always wraps in batchSpanProcessor) doesn't fit - e.g., custom batching parameters, custom processor implementations, or a compositeSpanProcessor over several inner processors.
Registers a SpanProcessor produced by a factory invoked inside the SDK's TraceExportConfigDsl scope. Use this when the convenience addSpanExporter (which always wraps in batchSpanProcessor) doesn't fit - e.g., custom batching parameters, custom processor implementations, or a compositeSpanProcessor over several inner processors.
Java-friendly entry point for the W&B Weave integration. Mirrors the commonMain addWeaveExporter but accepts java.time.Duration for timeout - the commonMain overload uses kotlin.time.Duration, whose value-class JVM-name mangling hides the timeout overload from Java callers.
Configures a span exporter that sends data to W&B Weave and installs the Weave SpanAdapter that reshapes spans to the Weave-recommended attribute layout.
Installs the W&B Weave SpanAdapter without registering the Weave cloud exporter. Spans are reshaped to the Weave-recommended attribute layout but are emitted only through whatever exporters the caller registers separately.
Restricts tool names in the attributes' metric and sets the fallback tool name when a tool is not allowed. Helps to manage cardinality of the metric.
Injects a pre-built Kotlin OpenTelemetry SDK to use for tracing.
Injects a pre-built Kotlin OpenTelemetry SDK to use for tracing.
Injects a pre-built Kotlin OpenTelemetry SDK to use for tracing.
Sets the service information reported in resource attributes.
Java-friendly 2-arg overload of setServiceInfo that omits the optional serviceNamespace.
Sets the service information reported in resource attributes.
Sets the service information reported in resource attributes.
Toggles whether OpenTelemetryPlatform.shutdown runs when the agent closes. See isShutdownOnAgentClose.
Toggles whether OpenTelemetryPlatform.shutdown runs when the agent closes. See isShutdownOnAgentClose.
Toggles whether OpenTelemetryPlatform.shutdown runs when the agent closes. See isShutdownOnAgentClose.