open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
752 stars 186 forks source link

[opentelemetry-php-contrib symfony] Span status is incorrectly set to error of 4xx responses. #1403

Closed technimad-splunk closed 4 weeks ago

technimad-splunk commented 1 month ago

What is the expected behavior? The instrumentation honours the semantic conventions for error spans: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status According to the otel semantic conventions, for 4xx status, the span status MUST be left unset for spans with SpanKind.SERVER.

What is the actual behavior? For any error a stack trace and span status of error is sent.

Additional context In Symfony applications, all errors are treated as exceptions, no matter if they are a 404 Not Found error or a fatal error triggered by throwing some exception in your code. If a handled request contains an exception, the auto instrumentation adds the exception to the span and sets the span kind to error. (L107 L163). The span status can be left unset if the response status code is in the 4xx range, as SymfonyInstrumentation.php only handles requests with SpanKind of server and internal.

brettmc commented 4 weeks ago

Fixed by https://github.com/open-telemetry/opentelemetry-php-contrib/pull/308