Skip to content

Commit e3b7fbe

Browse files
authored
chore: avoid logging an error for requests without tracing context (#117)
Resolves #116
1 parent 630a7fe commit e3b7fbe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/request_tracing.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,12 @@ RequestTracing::RequestTracing(ngx_http_request_t *request,
215215
NgxHeaderReader reader{&request->headers_in.headers};
216216
auto maybe_span = tracer->extract_span(reader);
217217
if (auto *error = maybe_span.if_error()) {
218-
ngx_log_error(
219-
NGX_LOG_ERR, request->connection->log, 0,
220-
"failed to extract a Datadog span request %p: [error code %d]: %s",
221-
request, error->code, error->message.c_str());
218+
if (error->code != dd::Error::NO_SPAN_TO_EXTRACT) {
219+
ngx_log_error(
220+
NGX_LOG_ERR, request->connection->log, 0,
221+
"failed to extract a Datadog span request %p: [error code %d]: %s",
222+
request, error->code, error->message.c_str());
223+
}
222224
request_span_.emplace(tracer->create_span(config));
223225
} else {
224226
request_span_.emplace(std::move(*maybe_span));

0 commit comments

Comments
 (0)