// Route: GET /context/trace (traceparent continuation, correlation id) #include "support/Assert.hpp" using namespace molo::example::test; using molo::example::fw::Method; int main() { Fixture f; std::string tid = "4bf92f3577b34da6a3ce929d0e0e4736"; auto cont = f.client->request(Method::Get, "/context/trace", "", {{"traceparent", "00-" + tid + "-00f067aa0ba902b7-01"}, {"X-Correlation-ID", "corr-9"}}); check(cont.status == 200, "status 200"); check(contains(cont.body, "\"trace_id\":\"" + tid), "trace id continued"); check(contains(cont.body, "\"parent_span_id\":\"00f067aa0ba902b7\""), "parent span reported"); check(cont.headers.get("traceparent").rfind("00-" + tid + "-", 0) == 0, "response traceparent same trace"); check(!contains(cont.headers.get("traceparent"), "00f067aa0ba902b7"), "new span id"); check(cont.headers.get("X-Correlation-ID") == "corr-9", "correlation propagated"); auto fresh = f.client->get("/context/trace"); check(contains(fresh.body, "\"continued\":false") && contains(fresh.body, "\"parent_valid\":true"), "new trace"); check(fresh.headers.get("X-Correlation-ID").rfind("req-", 0) == 0, "falls back to request id"); auto bad = f.client->request(Method::Get, "/context/trace", "", {{"traceparent", "garbage"}}); check(contains(bad.body, "\"parent_valid\":false") && contains(bad.body, "\"continued\":false"), "invalid parent restarts trace"); check(f.client->request(Method::Post, "/context/trace").status == 405, "post is 405"); return finish("context/trace"); }