From 60ea9008565a758f9235d90cfa43c4b5a38ae435 Mon Sep 17 00:00:00 2001 From: Keshav Manghat Date: Mon, 3 Aug 2020 21:39:47 -0600 Subject: [PATCH] Added a copy constructor for zpages recordable (#227) --- .../ext/zpages/threadsafe_span_data.h | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h index 66a4c81dfb5..b6a455dff2e 100644 --- a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h +++ b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h @@ -183,7 +183,28 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable // TODO: handle attributes } + ThreadsafeSpanData() {} + ThreadsafeSpanData(const ThreadsafeSpanData &threadsafe_span_data) + : ThreadsafeSpanData(threadsafe_span_data, + std::lock_guard(threadsafe_span_data.mutex_)) + {} + private: + ThreadsafeSpanData(const ThreadsafeSpanData &threadsafe_span_data, + const std::lock_guard &) + : trace_id_(threadsafe_span_data.trace_id_), + span_id_(threadsafe_span_data.span_id_), + parent_span_id_(threadsafe_span_data.parent_span_id_), + start_time_(threadsafe_span_data.start_time_), + duration_(threadsafe_span_data.duration_), + name_(threadsafe_span_data.name_), + status_code_(threadsafe_span_data.status_code_), + status_desc_(threadsafe_span_data.status_desc_), + attributes_(threadsafe_span_data.attributes_), + events_(threadsafe_span_data.events_), + converter_(threadsafe_span_data.converter_) + {} + mutable std::mutex mutex_; opentelemetry::trace::TraceId trace_id_; opentelemetry::trace::SpanId span_id_;