setSdk

abstract fun setSdk(openTelemetry: OpenTelemetry)(source)

Injects a pre-built Kotlin OpenTelemetry SDK to use for tracing.

When set, the feature uses openTelemetry as-is and skips internal SDK construction - meaning addSpanProcessor, addResourceAttributes, setServiceInfo, and the addLangfuseExporter / addWeaveExporter / addDatadogExporter integration helpers all become inert. Use this escape hatch when you need full control over the SDK: custom samplers, custom span processors, custom span limits, resource detectors, etc.

Build the SDK with io.opentelemetry.kotlin.createOpenTelemetry { … } and hand it off:

setSdk(
createOpenTelemetry {
tracerProvider {
resource(mapOf("service.name" to "my-agent"))
sampler { parentBased(root = alwaysOn()) }
export { batchSpanProcessor(myExporter) }
}
}
)

The instrumentation scope name/version reported by tracer still come from setServiceInfo (or the defaults). If you need them inside the SDK's resource attributes, set them in the resource(...) block of your createOpenTelemetry { } call.

Parameters

openTelemetry

Pre-built SDK instance to use.