From 2d0ee478a06b0de5470276022d3b6ed74301f847 Mon Sep 17 00:00:00 2001 From: esigo Date: Tue, 21 Dec 2021 15:49:31 +0100 Subject: [PATCH] InMemorySpanExporter shutdown fix --- .../exporters/memory/in_memory_span_exporter.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h index 94e9e7f929..0c2c537838 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h @@ -42,6 +42,10 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte sdk::common::ExportResult Export( const nostd::span> &recordables) noexcept override { + if (is_shutdown_) + { + return sdk::common::ExportResult::kFailure; + } for (auto &recordable : recordables) { auto span = std::unique_ptr( @@ -63,6 +67,7 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte bool Shutdown( std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override { + is_shutdown_ = true; return true; }; @@ -76,6 +81,7 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte private: std::shared_ptr data_; + bool is_shutdown_ = false; }; } // namespace memory } // namespace exporter