]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentracing-cpp/mocktracer/src/json_recorder.cpp
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / opentracing-cpp / mocktracer / src / json_recorder.cpp
CommitLineData
f67539c2
TL
1#include <opentracing/mocktracer/json.h>
2#include <opentracing/mocktracer/json_recorder.h>
3
4namespace opentracing {
5BEGIN_OPENTRACING_ABI_NAMESPACE
6namespace mocktracer {
7JsonRecorder::JsonRecorder(std::unique_ptr<std::ostream>&& out)
8 : out_{std::move(out)} {}
9
10void JsonRecorder::RecordSpan(SpanData&& span_data) noexcept try {
11 std::lock_guard<std::mutex> lock_guard{mutex_};
12 spans_.emplace_back(std::move(span_data));
13} catch (const std::exception&) {
14 // Drop span.
15}
16
17void JsonRecorder::Close() noexcept try {
18 if (out_ == nullptr) {
19 return;
20 }
21 std::lock_guard<std::mutex> lock_guard{mutex_};
22 ToJson(*out_, spans_);
23 out_->flush();
24 spans_.clear();
25} catch (const std::exception&) {
26 // Ignore errors.
27}
28} // namespace mocktracer
29END_OPENTRACING_ABI_NAMESPACE
30} // namespace opentracing