@@ -36,9 +36,8 @@ public function setUp(): void
3636
3737 public function testCollectRequest (): void
3838 {
39- $ metrics = new AppMetrics ();
39+ $ metrics = new AppMetrics ($ this -> labelResolver );
4040 $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
41- $ metrics ->setLabelResolver ($ this ->labelResolver );
4241
4342 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'GET ' ]);
4443 $ evt = $ this ->createMock (RequestEvent::class);
@@ -56,9 +55,8 @@ public function testCollectRequest(): void
5655
5756 public function testCollectRequestOptionsMethod (): void
5857 {
59- $ metrics = new AppMetrics ();
58+ $ metrics = new AppMetrics ($ this -> labelResolver );
6059 $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
61- $ metrics ->setLabelResolver ($ this ->labelResolver );
6260
6361 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'OPTIONS ' ]);
6462 $ evt = $ this ->createMock (RequestEvent::class);
@@ -92,9 +90,8 @@ public static function provideMetricsName(): array
9290 */
9391 public function testCollectResponse (int $ code , string $ metricsName ): void
9492 {
95- $ metrics = new AppMetrics ();
93+ $ metrics = new AppMetrics ($ this -> labelResolver );
9694 $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
97- $ metrics ->setLabelResolver ($ this ->labelResolver );
9895
9996 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'GET ' ]);
10097 $ response = new Response ('' , $ code );
@@ -116,9 +113,8 @@ public function testSetRequestDuration(): void
116113 {
117114 self ::registerMicrotimeMock ('Artprima\PrometheusMetricsBundle\Metrics ' );
118115
119- $ metrics = new AppMetrics ();
116+ $ metrics = new AppMetrics ($ this -> labelResolver );
120117 $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
121- $ metrics ->setLabelResolver ($ this ->labelResolver );
122118
123119 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'GET ' ]);
124120 $ reqEvt = $ this ->createMock (RequestEvent::class);
@@ -159,10 +155,8 @@ public function testSetRequestDuration(): void
159155
160156 public function testUseMetricInfoResolver (): void
161157 {
162- $ metrics = new AppMetrics ();
158+ $ metrics = new AppMetrics ($ this -> labelResolver , new DummyMetricInfoResolver () );
163159 $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
164- $ metrics ->setLabelResolver ($ this ->labelResolver );
165- $ metrics ->setMetricInfoResolver (new DummyMetricInfoResolver ());
166160
167161 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'GET ' , 'REQUEST_URI ' => 'https://example.com/test?query=1 ' ]);
168162 $ reqEvt = $ this ->createMock (RequestEvent::class);
@@ -186,14 +180,13 @@ public function testUseMetricInfoResolver(): void
186180
187181 public function testUseMetricInfoResolverWithLabels (): void
188182 {
189- $ metrics = new AppMetrics ();
190- $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
191- $ metrics ->setMetricInfoResolver (new DummyMetricInfoResolver ());
192183 $ labels = [
193184 new LabelConfig ('color ' , LabelConfig::REQUEST_ATTRIBUTE , 'color ' ),
194185 new LabelConfig ('client_name ' , LabelConfig::REQUEST_HEADER , 'X-Client-Name ' ),
195186 ];
196- $ metrics ->setLabelResolver (new LabelResolver ($ labels ));
187+
188+ $ metrics = new AppMetrics (new LabelResolver ($ labels ), new DummyMetricInfoResolver ());
189+ $ metrics ->init ($ this ->namespace , $ this ->collectionRegistry );
197190
198191 $ request = new Request ([], [], ['_route ' => 'test_route ' ], [], [], ['REQUEST_METHOD ' => 'GET ' , 'REQUEST_URI ' => 'https://example.com/test?query=1 ' ]);
199192
0 commit comments