Skip to content

Commit

Permalink
fix: set error status on span with 5xx status code (#443)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Mehala authored Jun 9, 2024
1 parent 58601e5 commit 415f182
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion instrumentation/nginx/src/otel_ngx_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,14 @@ ngx_int_t FinishNgxSpan(ngx_http_request_t* req) {
}

auto span = context->request_span;
span->SetAttribute("http.status_code", req->headers_out.status);
const auto status_code = req->headers_out.status;
span->SetAttribute("http.status_code", status_code);

if (status_code >= 500) {
span->SetStatus(trace::StatusCode::kError);
} else {
span->SetStatus(trace::StatusCode::kOk);
}

OtelNgxLocationConf* locConf = GetOtelLocationConf(req);

Expand Down

0 comments on commit 415f182

Please sign in to comment.