summaryrefslogtreecommitdiffstats
path: root/mocktracer/src/mock_span.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:44:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:44:33 +0000
commitb196c6498d22e47bb9d0da0153068ec54eac7956 (patch)
tree1a994a492581e93224a7ee6455f5d4e9d2ec8e59 /mocktracer/src/mock_span.h
parentInitial commit. (diff)
downloadopentracing-cpp-b196c6498d22e47bb9d0da0153068ec54eac7956.tar.xz
opentracing-cpp-b196c6498d22e47bb9d0da0153068ec54eac7956.zip
Adding upstream version 1.6.0.upstream/1.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mocktracer/src/mock_span.h')
-rw-r--r--mocktracer/src/mock_span.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/mocktracer/src/mock_span.h b/mocktracer/src/mock_span.h
new file mode 100644
index 0000000..bf8ba05
--- /dev/null
+++ b/mocktracer/src/mock_span.h
@@ -0,0 +1,66 @@
+#ifndef OPENTRACING_MOCKTRACER_SPAN_H
+#define OPENTRACING_MOCKTRACER_SPAN_H
+
+#include <opentracing/mocktracer/tracer.h>
+#include <atomic>
+#include <mutex>
+#include "mock_span_context.h"
+
+namespace opentracing {
+BEGIN_OPENTRACING_ABI_NAMESPACE
+namespace mocktracer {
+
+class MockSpan : public Span {
+ public:
+ MockSpan(std::shared_ptr<const Tracer>&& tracer, Recorder* recorder,
+ string_view operation_name, const StartSpanOptions& options);
+
+ ~MockSpan() override;
+
+ void FinishWithOptions(const FinishSpanOptions& options) noexcept override;
+
+ void SetOperationName(string_view name) noexcept override;
+
+ void SetTag(string_view key,
+ const opentracing::Value& value) noexcept override;
+
+ void Log(std::initializer_list<std::pair<string_view, Value>>
+ fields) noexcept override;
+
+ void Log(SystemTime timestamp,
+ std::initializer_list<std::pair<string_view, Value>>
+ fields) noexcept override;
+
+ void Log(SystemTime timestamp,
+ const std::vector<std::pair<string_view, Value>>&
+ fields) noexcept override;
+
+ void SetBaggageItem(string_view restricted_key,
+ string_view value) noexcept override;
+
+ std::string BaggageItem(string_view restricted_key) const noexcept override;
+
+ const SpanContext& context() const noexcept override { return span_context_; }
+
+ const opentracing::Tracer& tracer() const noexcept override {
+ return *tracer_;
+ }
+
+ private:
+ std::shared_ptr<const Tracer> tracer_;
+ Recorder* recorder_;
+ MockSpanContext span_context_;
+ SteadyTime start_steady_;
+
+ std::atomic<bool> is_finished_{false};
+
+ // Mutex protects data_
+ std::mutex mutex_;
+ SpanData data_;
+};
+
+} // namespace mocktracer
+END_OPENTRACING_ABI_NAMESPACE
+} // namespace opentracing
+
+#endif // OPENTRACING_MOCKTRACER_SPAN_H