Branch data Line data Source code
1 : : #pragma once
2 : :
3 : : #include <hpactor/tracing/trace_exporter.hpp>
4 : :
5 : : #include <fstream>
6 : : #include <mutex>
7 : : #include <string>
8 : :
9 : : namespace hpactor::tracing {
10 : :
11 : : class JsonFileExporter final : public SpanExporter {
12 : : public:
13 : : explicit JsonFileExporter(std::string path);
14 : : result<void> export_batch(std::span<const SpanRecord> batch) noexcept override;
15 : : void shutdown() noexcept override;
16 : 0 : const char* name() const noexcept override {
17 : 0 : return "json_file";
18 : : }
19 : :
20 : : private:
21 : : std::string path_;
22 : : std::ofstream out_;
23 : : std::mutex mutex_;
24 : : };
25 : :
26 : : std::string span_record_to_json(const SpanRecord& record);
27 : :
28 : : } // namespace hpactor::tracing
|