Skip to content

Commit 83d9621

Browse files
committed
do not raise error if header extraction fails, on start span raise vailidation error iff parent_id=0
1 parent 7717d47 commit 83d9621

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/system-tests/request_handler.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ void RequestHandler::on_span_start(const httplib::Request& req,
127127
std::to_string(*parent_id);
128128
VALIDATION_ERROR(res, msg);
129129
}
130-
} else {
130+
} else if (*parent_id != 0) {
131131
const auto msg = "on_span_start: span or http_headers not found for id " +
132132
std::to_string(*parent_id);
133133
VALIDATION_ERROR(res, msg);
134+
} else {
135+
auto span = tracer_.create_span(span_cfg);
136+
success(span, res);
137+
active_spans_.emplace(span.id(), std::move(span));
134138
}
135139
} else {
136140
auto span = tracer_.create_span(span_cfg);
@@ -245,8 +249,15 @@ void RequestHandler::on_extract_headers(const httplib::Request& req,
245249
// The span below will not be finished and flushed.
246250
auto span =
247251
tracer_.extract_span(utils::HeaderReader(*http_headers), span_cfg);
252+
248253
if (auto error = span.if_error()) {
249-
VALIDATION_ERROR(res, error->with_prefix("on_extract_headers: ").message);
254+
// clang-format off
255+
const auto response_body_fail = nlohmann::json{
256+
{"span_id", nullptr},
257+
};
258+
// clang-format on
259+
res.set_content(response_body_fail.dump(), "application/json");
260+
return;
250261
}
251262

252263
// clang-format off

0 commit comments

Comments
 (0)