Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
24 lines
715 B
C++
24 lines
715 B
C++
#pragma once
|
|
// Spec: molo::app::seams::request_id. Correlation ID seam owned by
|
|
// 02-observability. Request ID is read from X-Request-ID when present, else
|
|
// generated. Middleware must preserve it (plan 05, section 6 Middleware).
|
|
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <string>
|
|
|
|
namespace molo::app::seams {
|
|
|
|
inline std::string generate_request_id() {
|
|
static std::atomic<std::uint64_t> counter{1};
|
|
std::uint64_t n = counter.fetch_add(1, std::memory_order_relaxed);
|
|
char buf[32];
|
|
std::snprintf(buf, sizeof(buf), "req-%016llx", (unsigned long long)n);
|
|
return std::string(buf);
|
|
}
|
|
|
|
inline constexpr const char* kRequestIdHeader = "X-Request-ID";
|
|
|
|
} // namespace molo::app::seams
|