LME-759: fix telemetry (langfuse) in AI Diff - 3

GitOrigin-RevId: 9f1ea1c58a0463f2b7abf9438049371985b3cf8c
This commit is contained in:
Dmitry Osinovskiy
2026-02-04 21:53:11 +01:00
committed by intellij-monorepo-bot
parent 725ac0dfc0
commit c83d711af5

View File

@@ -59,6 +59,19 @@ suspend inline fun <T> SpanBuilder.useWithScope(
}
}
/**
* Use this method if telemetry is optional and turned on/off based on registry keys or options
* Usage example:
* telemetryTracer?.spanBuilder(...).useOrRun {
* // some code that must be executed in any case, telemetry or not
* }
*
* Executes the given operation with a span builder, if it's not null, and returns the result.
* If the span builder is null, the operation is executed with a null span.
*
* @param operation The operation to execute with the span builder.
* @return The result of the operation.
*/
@Internal
suspend inline fun <T> SpanBuilder?.useOrRun(
crossinline operation: suspend (Span?) -> T,