66
77use OpenTelemetry \API \Trace \SpanKind ;
88use OpenTelemetry \API \Trace \StatusCode ;
9- use OpenTelemetry \Contrib \Propagation \ServerTiming \ServerTimingPropagator ;
10- use OpenTelemetry \Contrib \Propagation \TraceResponse \TraceResponsePropagator ;
119use OpenTelemetry \SemConv \TraceAttributes ;
1210use Symfony \Component \EventDispatcher \EventDispatcher ;
1311use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
@@ -31,14 +29,7 @@ public function test_http_kernel_handle_exception(): void
3129 throw new \RuntimeException ();
3230 });
3331 $ this ->assertCount (0 , $ this ->storage );
34-
35- $ response = $ kernel ->handle (new Request ());
36-
37- $ this ->assertArrayHasKey (
38- TraceResponsePropagator::TRACERESPONSE ,
39- $ response ->headers ->all (),
40- 'traceresponse header is present if TraceResponsePropagator is present '
41- );
32+ $ kernel ->handle (new Request ());
4233 }
4334
4435 public function test_http_kernel_marks_root_as_erroneous (): void
@@ -49,18 +40,12 @@ public function test_http_kernel_marks_root_as_erroneous(): void
4940 });
5041 $ this ->assertCount (0 , $ this ->storage );
5142
52- $ response = $ kernel ->handle (new Request (), HttpKernelInterface::MAIN_REQUEST , true );
43+ $ kernel ->handle (new Request (), HttpKernelInterface::MAIN_REQUEST , true );
5344
5445 $ this ->assertCount (1 , $ this ->storage );
5546 $ this ->assertSame (500 , $ this ->storage [0 ]->getAttributes ()->get (TraceAttributes::HTTP_RESPONSE_STATUS_CODE ));
5647
5748 $ this ->assertSame (StatusCode::STATUS_ERROR , $ this ->storage [0 ]->getStatus ()->getCode ());
58-
59- $ this ->assertArrayHasKey (
60- TraceResponsePropagator::TRACERESPONSE ,
61- $ response ->headers ->all (),
62- 'traceresponse header is present if TraceResponsePropagator is present '
63- );
6449 }
6550
6651 public function test_http_kernel_handle_attributes (): void
@@ -70,7 +55,7 @@ public function test_http_kernel_handle_attributes(): void
7055 $ request = new Request ();
7156 $ request ->attributes ->set ('_route ' , 'test_route ' );
7257
73- $ response = $ kernel ->handle ($ request );
58+ $ kernel ->handle ($ request );
7459
7560 $ attributes = $ this ->storage [0 ]->getAttributes ();
7661 $ this ->assertCount (1 , $ this ->storage );
@@ -83,17 +68,6 @@ public function test_http_kernel_handle_attributes(): void
8368 $ this ->assertEquals ('1.0 ' , $ attributes ->get (TraceAttributes::NETWORK_PROTOCOL_VERSION ));
8469 $ this ->assertEquals (5 , $ attributes ->get (TraceAttributes::HTTP_RESPONSE_BODY_SIZE ));
8570
86- $ this ->assertArrayHasKey (
87- TraceResponsePropagator::TRACERESPONSE ,
88- $ response ->headers ->all (),
89- 'traceresponse header is present if TraceResponsePropagator is present '
90- );
91-
92- $ this ->assertArrayHasKey (
93- ServerTimingPropagator::SERVER_TIMING ,
94- $ response ->headers ->all (),
95- 'server-timings header is present if ServerTimingPropagator is present '
96- );
9771 }
9872
9973 public function test_http_kernel_handle_stream_response (): void
@@ -104,43 +78,20 @@ public function test_http_kernel_handle_stream_response(): void
10478 }));
10579 $ this ->assertCount (0 , $ this ->storage );
10680
107- $ response = $ kernel ->handle (new Request ());
81+ $ kernel ->handle (new Request ());
10882 $ this ->assertCount (1 , $ this ->storage );
10983 $ this ->assertNull ($ this ->storage [0 ]->getAttributes ()->get (TraceAttributes::HTTP_RESPONSE_BODY_SIZE ));
110-
111- $ this ->assertArrayHasKey (
112- TraceResponsePropagator::TRACERESPONSE ,
113- $ response ->headers ->all (),
114- 'traceresponse header is present if TraceResponsePropagator is present '
115- );
116-
117- $ this ->assertArrayHasKey (
118- ServerTimingPropagator::SERVER_TIMING ,
119- $ response ->headers ->all (),
120- 'server-timings header is present if ServerTimingPropagator is present '
121- );
12284 }
12385
12486 public function test_http_kernel_handle_binary_file_response (): void
12587 {
12688 $ kernel = $ this ->getHttpKernel (new EventDispatcher (), fn () => new BinaryFileResponse (__FILE__ ));
12789 $ this ->assertCount (0 , $ this ->storage );
12890
129- $ response = $ kernel ->handle (new Request ());
91+ $ kernel ->handle (new Request ());
13092 $ this ->assertCount (1 , $ this ->storage );
13193 $ this ->assertNull ($ this ->storage [0 ]->getAttributes ()->get (TraceAttributes::HTTP_RESPONSE_BODY_SIZE ));
13294
133- $ this ->assertArrayHasKey (
134- TraceResponsePropagator::TRACERESPONSE ,
135- $ response ->headers ->all (),
136- 'traceresponse header is present if TraceResponsePropagator is present '
137- );
138-
139- $ this ->assertArrayHasKey (
140- ServerTimingPropagator::SERVER_TIMING ,
141- $ response ->headers ->all (),
142- 'server-timings header is present if ServerTimingPropagator is present '
143- );
14495 }
14596
14697 public function test_http_kernel_handle_with_empty_route (): void
@@ -150,43 +101,21 @@ public function test_http_kernel_handle_with_empty_route(): void
150101 $ request = new Request ();
151102 $ request ->attributes ->set ('_route ' , '' );
152103
153- $ response = $ kernel ->handle ($ request , HttpKernelInterface::MAIN_REQUEST , true );
104+ $ kernel ->handle ($ request , HttpKernelInterface::MAIN_REQUEST , true );
154105 $ this ->assertCount (1 , $ this ->storage );
155106 $ this ->assertFalse ($ this ->storage [0 ]->getAttributes ()->has (TraceAttributes::HTTP_ROUTE ));
156107
157- $ this ->assertArrayHasKey (
158- TraceResponsePropagator::TRACERESPONSE ,
159- $ response ->headers ->all (),
160- 'traceresponse header is present if TraceResponsePropagator is present '
161- );
162-
163- $ this ->assertArrayHasKey (
164- ServerTimingPropagator::SERVER_TIMING ,
165- $ response ->headers ->all (),
166- 'server-timings header is present if ServerTimingPropagator is present '
167- );
168108 }
169109
170110 public function test_http_kernel_handle_without_route (): void
171111 {
172112 $ kernel = $ this ->getHttpKernel (new EventDispatcher ());
173113 $ this ->assertCount (0 , $ this ->storage );
174114
175- $ response = $ kernel ->handle (new Request (), HttpKernelInterface::MAIN_REQUEST , true );
115+ $ kernel ->handle (new Request (), HttpKernelInterface::MAIN_REQUEST , true );
176116 $ this ->assertCount (1 , $ this ->storage );
177117 $ this ->assertFalse ($ this ->storage [0 ]->getAttributes ()->has (TraceAttributes::HTTP_ROUTE ));
178118
179- $ this ->assertArrayHasKey (
180- TraceResponsePropagator::TRACERESPONSE ,
181- $ response ->headers ->all (),
182- 'traceresponse header is present if TraceResponsePropagator is present '
183- );
184-
185- $ this ->assertArrayHasKey (
186- ServerTimingPropagator::SERVER_TIMING ,
187- $ response ->headers ->all (),
188- 'server-timings header is present if ServerTimingPropagator is present '
189- );
190119 }
191120
192121 public function test_http_kernel_handle_subrequest (): void
0 commit comments