Skip to content

Commit

Permalink
Added a copy constructor for zpages recordable (open-telemetry#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmanghat authored Aug 4, 2020
1 parent 8a02381 commit 60ea900
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex>(threadsafe_span_data.mutex_))
{}

private:
ThreadsafeSpanData(const ThreadsafeSpanData &threadsafe_span_data,
const std::lock_guard<std::mutex> &)
: 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_;
Expand Down

0 comments on commit 60ea900

Please sign in to comment.