Skip to content

Commit

Permalink
Leave span status unset on success
Browse files Browse the repository at this point in the history
  • Loading branch information
jjatria committed May 8, 2024
1 parent cec3db0 commit c508db6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Revision history for Dancer2-Plugin-OpenTelemetry

{{$NEXT}}

* Spans are no longer automatically marked as OK by this
instrumentation. This is inline with the specification.
The documentation has been updated to reflect this.

0.002 2024-05-02 21:51:02+01:00 Europe/London

* Fixed an issue where spans were set to error in the case of 4XX
Expand Down
5 changes: 1 addition & 4 deletions lib/Dancer2/Plugin/OpenTelemetry.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ sub BUILD ( $plugin, @ ) {
my $span = otel_span_from_context;
my $code = $res->status;

if ($code < 400) {
$span->set_status(SPAN_STATUS_OK );
}
elsif ($code >= 500) {
if ($code >= 500) {
$span->set_status(SPAN_STATUS_ERROR);
}

Expand Down
19 changes: 14 additions & 5 deletions lib/Dancer2/Plugin/OpenTelemetry.pod
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,20 @@ C<500>.
=back

The span will be unconditionally L<ended|OpenTelemetry::Trace::Span/end> after
the request has been handled, and the
L<status will be set|OpenTelemetry::Trace::Span/set_status> to either an
L<OK status|OpenTelemetry::Constants/SPAN_STATUS_OK> if no errors were found,
or to an L<error status|OpenTelemetry::Constants/SPAN_STATUS_ERROR> otherwise.
In the latter case, an error description will also be set if possible.
the action has completed, and the
L<status will be set|OpenTelemetry::Trace::Span/set_status> to an
L<error status|OpenTelemetry::Constants/SPAN_STATUS_ERROR> if the response
result in a server error (any HTTP status greater than or equal to 500).

If an exception is raised during the execution of the action, this will be
caught and the description of the error status will be based on the message
in that exception (otherwise no description will be set). The description
will contain the first line of the exception body, minus any trailing
markers of where the error took place, with the aim to make it safe to be
exposed without leaking too much internal information.

Any exceptions caught by this integration will be re-thrown to be handled
downstream.

=head2 Internal redirects

Expand Down

0 comments on commit c508db6

Please sign in to comment.