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)
{

View File

@@ -1,5 +1,5 @@
add_unit_test(
environment_ut
"context_ut.cc;parsing_ut.cc;base_evaluators_ut.cc;environment_rest_ut.cc;span_ut.cc;trace_ut.cc;tracing_ut.cc;environment_ut.cc"
"environment;singleton;rest;mainloop;metric;-lboost_context;event_is;-lboost_regex"
"environment;messaging;singleton;rest;mainloop;metric;-lboost_context;event_is;-lboost_regex"
)

0
core/environment/environment_ut/base_evaluators_ut.cc Executable file → Normal file
View File

0
core/environment/environment_ut/context_ut.cc Executable file → Normal file
View File

0
core/environment/environment_ut/parsing_ut.cc Executable file → Normal file
View File

0
core/environment/environment_ut/span_ut.cc Executable file → Normal file
View File

0
core/environment/environment_ut/trace_ut.cc Executable file → Normal file
View File

2
core/environment/environment_ut/tracing_ut.cc Executable file → Normal file
View File

@@ -344,8 +344,6 @@ public:
TEST_F(TracingCompRoutinesTest, 2SpansDifFlow)
{
ON_CALL(mock_messaging, mockSendPersistentMessage(_, _, _, _, _, _, _)).WillByDefault(Return(string()));
I_MainLoop::Routine routine = [&] () {
i_env->startNewTrace(true, "a687b388-1108-4083-9852-07c33b1074e9");
trace_id = i_env->getCurrentTrace();

0
core/environment/span.cc Executable file → Normal file
View File

0
core/environment/trace.cc Executable file → Normal file
View File