55namespace OpenTelemetry \Tests \Instrumentation \Symfony \tests \Integration ;
66
77use OpenTelemetry \API \Trace \SpanKind ;
8+ use OpenTelemetry \API \Trace \StatusCode ;
89use OpenTelemetry \Contrib \Propagation \ServerTiming \ServerTimingPropagator ;
910use OpenTelemetry \Contrib \Propagation \TraceResponse \TraceResponsePropagator ;
1011use OpenTelemetry \SDK \Trace \ImmutableSpan ;
1819use Symfony \Component \HttpFoundation \StreamedResponse ;
1920use Symfony \Component \HttpKernel \Controller \ArgumentResolverInterface ;
2021use Symfony \Component \HttpKernel \Controller \ControllerResolverInterface ;
22+ use Symfony \Component \HttpKernel \Exception \HttpException ;
2123use Symfony \Component \HttpKernel \HttpKernel ;
2224use Symfony \Component \HttpKernel \HttpKernelInterface ;
2325
@@ -40,6 +42,28 @@ public function test_http_kernel_handle_exception(): void
4042 );
4143 }
4244
45+ public function test_http_kernel_marks_root_as_erroneous (): void
46+ {
47+ $ this ->expectException (HttpException::class);
48+ $ kernel = $ this ->getHttpKernel (new EventDispatcher (), function () {
49+ throw new HttpException (500 , 'foo ' );
50+ });
51+ $ this ->assertCount (0 , $ this ->storage );
52+
53+ $ response = $ kernel ->handle (new Request (), HttpKernelInterface::MAIN_REQUEST , true );
54+
55+ $ this ->assertCount (1 , $ this ->storage );
56+ $ this ->assertSame (500 , $ this ->storage [0 ]->getAttributes ()->get (TraceAttributes::HTTP_RESPONSE_STATUS_CODE ));
57+
58+ $ this ->assertSame (StatusCode::STATUS_ERROR , $ this ->storage [0 ]->getStatus ()->getCode ());
59+
60+ $ this ->assertArrayHasKey (
61+ TraceResponsePropagator::TRACERESPONSE ,
62+ $ response ->headers ->all (),
63+ 'traceresponse header is present if TraceResponsePropagator is present '
64+ );
65+ }
66+
4367 public function test_http_kernel_handle_attributes (): void
4468 {
4569 $ kernel = $ this ->getHttpKernel (new EventDispatcher ());
0 commit comments