Skip to content

Commit

Permalink
fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dmehala committed Dec 2, 2024
1 parent b35ee1c commit 55ec27d
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions test/system-tests/request_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,35 +221,30 @@ void RequestHandler::on_inject_headers(const httplib::Request& req,
res.set_content(response_json.dump(), "application/json");
}


void RequestHandler::on_extract_headers(const httplib::Request& req,
httplib::Response& res) {
httplib::Response& res) {
const auto request_json = nlohmann::json::parse(req.body);
auto http_headers = utils::get_if_exists<nlohmann::json::array_t>(request_json, "http_headers");
auto http_headers = utils::get_if_exists<nlohmann::json::array_t>(
request_json, "http_headers");
if (!http_headers) {
VALIDATION_ERROR(res, "on_extract_headers: missing `http_headers` field.");
}

datadog::tracing::SpanConfig span_cfg;
auto span = tracer_.extract_span(
utils::HeaderReader(*http_headers), span_cfg);

auto success = [](const datadog::tracing::Span& span,
httplib::Response& res) {
// clang-format off
const auto response_body = nlohmann::json{
{ "span_id", span.id() }
};
// clang-format on
auto span =
tracer_.extract_span(utils::HeaderReader(*http_headers), span_cfg);
if (auto error = span.if_error()) {
VALIDATION_ERROR(res, error->with_prefix("on_extract_headers: ").message);
}

res.set_content(response_body.dump(), "application/json");
const auto response_body = nlohmann::json{
{"span_id", span->id()},
};

success(span, res);
spans_.emplace(span.id(), std::move(span));
res.set_content(response_body.dump(), "application/json");
spans_.emplace(span->id(), std::move(*span));
}


void RequestHandler::on_span_flush(const httplib::Request& /* req */,
httplib::Response& res) {
scheduler_->flush_telemetry();
Expand Down

0 comments on commit 55ec27d

Please sign in to comment.