mirror of
https://github.com/openappsec/openappsec.git
synced 2025-11-17 09:45:29 +03:00
Jan_31_2024-Dev
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user