Skip to content

Commit

Permalink
Mark span as error if not success response
Browse files Browse the repository at this point in the history
  • Loading branch information
jjatria committed Dec 3, 2023
1 parent e04fd32 commit d846630
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/Mojolicious/Plugin/OpenTelemetry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ sub register ( $, $app, $config, @ ) {
: Mojo::Promise->resolve(1);

$promise->then( sub {
my $code = $tx->res->code;
my $error = $code >= 400 && $code < 600;

$span
->set_status( SPAN_STATUS_OK )
->set_attribute(
'http.response.status_code' => $tx->res->code,
)
->set_status( $error ? SPAN_STATUS_ERROR : SPAN_STATUS_OK )
->set_attribute( 'http.response.status_code' => $code )
->end;
})->wait;

Expand Down

0 comments on commit d846630

Please sign in to comment.