addSpanProcessor
expect open override fun addSpanProcessor(factory: TraceExportConfigDsl.() -> SpanProcessor)(source)
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.
Example:
addSpanProcessor { batchSpanProcessor(myOtlpExporter, scheduleDelayMs = 500) }
addSpanProcessor { compositeSpanProcessor(p1, p2) }Content copied to clipboard
For Java SDK exporters, wrap with toOtelKotlinSpanExporter() from the compat package first.
Parameters
factory
Lambda that returns the SpanProcessor when invoked inside the SDK's export-config DSL.