From f210998e99a0245ef2401ba4fb7fce3e5e66010f Mon Sep 17 00:00:00 2001 From: Arriana Blais Date: Thu, 12 Dec 2024 10:31:45 -0500 Subject: [PATCH] make the span exporter flush result after export --- .../Trace/SpanProcessors/BatchSpanProcessor.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/OpenTelemetrySdk/Trace/SpanProcessors/BatchSpanProcessor.swift b/Sources/OpenTelemetrySdk/Trace/SpanProcessors/BatchSpanProcessor.swift index 7c79d7b3..575ffeed 100644 --- a/Sources/OpenTelemetrySdk/Trace/SpanProcessors/BatchSpanProcessor.swift +++ b/Sources/OpenTelemetrySdk/Trace/SpanProcessors/BatchSpanProcessor.swift @@ -222,7 +222,12 @@ private class BatchWorker: Thread { stride(from: 0, to: spanList.endIndex, by: maxExportBatchSize).forEach { var spansToExport = spanList[$0 ..< min($0 + maxExportBatchSize, spanList.count)].map { $0.toSpanData() } willExportCallback?(&spansToExport) - let result = spanExporter.export(spans: spansToExport, explicitTimeout: explicitTimeout) + var result = spanExporter.export(spans: spansToExport, explicitTimeout: explicitTimeout) + + if result == .success { + result = spanExporter.flush(explicitTimeout: explicitTimeout) + } + if result == .success { cond.lock() processedSpansCounter?.add(value: spanList.count, attribute: [