Jan_31_2024-Dev

This commit is contained in:
Ned Wright
2024-01-31 17:34:53 +00:00
parent 752a5785f0
commit 6d67818a94
376 changed files with 8101 additions and 7064 deletions

View File

@@ -59,6 +59,7 @@ public:
string getCurrentTrace() const override;
string getCurrentSpan() const override;
string getCurrentHeaders() override;
map<string, string> getCurrentHeadersMap() override;
void startNewTrace(bool new_span, const string &_trace_id) override;
void startNewSpan(Span::ContextType _type, const string &prev_span, const string &trace) override;
@@ -266,6 +267,34 @@ Environment::Impl::getCurrentHeaders()
return tracing_headers;
}
map<string, string>
Environment::Impl::getCurrentHeadersMap()
{
map<string, string> tracing_headers;
auto trace_id = getCurrentTrace();
if (!trace_id.empty()) {
tracing_headers["X-Trace-Id"] = trace_id;
} else {
string correlation_id_string = "00000000-0000-0000-0000-000000000000";
try {
boost::uuids::random_generator uuid_random_gen;
correlation_id_string = boost::uuids::to_string(uuid_random_gen());
} catch (const boost::uuids::entropy_error &e) {
dbgTrace(D_ENVIRONMENT)
<< "Failed to generate random correlation id - entropy exception. Exception: "
<< e.what();
tracing_status = TracingStatus::DISABLED;
}
tracing_headers["X-Trace-Id"] = correlation_id_string;
}
auto span_id = getCurrentSpan();
if (!span_id.empty()) {
tracing_headers["X-Span-Id"] = span_id;
}
return tracing_headers;
}
void
Environment::Impl::startNewTrace(bool new_span, const string &_trace_id)
{