Observability: W3C traceparent/tracestate/baggage propagation (S-OBSERVABILITY-05)
This commit is contained in:
1 parent
404bf4ce2f
commit
cc41e5b1d9
3 files changed
+415
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/Observability/Context.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Observability
|
||||
{
|
||||
/// A transport header (HTTP, SMTP, message metadata, ...).
|
||||
struct HeaderField {
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct PropagationLimits {
|
||||
/// Maximum size of the serialized tracestate header.
|
||||
std::size_t max_tracestate_bytes{512};
|
||||
/// Maximum number of tracestate list members.
|
||||
std::size_t max_tracestate_members{32};
|
||||
};
|
||||
|
||||
/// Context extracted from headers, with the vendor tracestate preserved
|
||||
/// (Void does not interpret foreign vendors' state).
|
||||
struct CarriedContext {
|
||||
ContextSnapshot context{};
|
||||
std::string tracestate{};
|
||||
};
|
||||
|
||||
/// Extract W3C traceparent, tracestate and baggage from headers.
|
||||
///
|
||||
/// Header names are matched case-insensitively. A malformed traceparent or
|
||||
/// tracestate, duplicate tracestate keys, or a payload exceeding the limits
|
||||
/// is an error rather than silently dropped context.
|
||||
[[nodiscard]] Void::Result::Result<CarriedContext>
|
||||
extract_context(std::span<const HeaderField> headers,
|
||||
ContextLimits context_limits = {},
|
||||
PropagationLimits propagation_limits = {});
|
||||
|
||||
/// Serialize context back to headers: traceparent when a trace exists,
|
||||
/// tracestate when non-empty, and baggage when present.
|
||||
[[nodiscard]] Void::Result::Result<std::vector<HeaderField>>
|
||||
inject_context(const CarriedContext& carried);
|
||||
} // namespace Void::Observability
|
||||
Reference in new issue
Block a user