Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
trace_context.h
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
12#pragma once
13#include <string>
14#include <chrono>
15#include <optional>
16
17namespace kcenon { namespace monitoring {
18
19struct trace_context {
20 std::string trace_id;
21 std::string span_id;
22 std::optional<std::string> parent_span_id;
23 std::chrono::system_clock::time_point start_time;
24
25 static trace_context create_root(const std::string& operation) {
26 return {generate_id(), generate_id(), std::nullopt,
27 std::chrono::system_clock::now()};
28 }
29
30 trace_context create_child(const std::string& operation) const {
31 return {trace_id, generate_id(), span_id,
32 std::chrono::system_clock::now()};
33 }
34
35private:
36 static std::string generate_id();
37};
38
39} // namespace