@@ -39,8 +39,6 @@ public void RenderStart_IncreasesCounters()
3939 var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
4040 using var totalCounter = new MetricCollector < long > ( _meterFactory ,
4141 RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
42- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
43- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
4442
4543 var componentType = "TestComponent" ;
4644
@@ -49,24 +47,17 @@ public void RenderStart_IncreasesCounters()
4947
5048 // Assert
5149 var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
52- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
5350
5451 Assert . Single ( totalMeasurements ) ;
5552 Assert . Equal ( 1 , totalMeasurements [ 0 ] . Value ) ;
5653 Assert . Equal ( componentType , totalMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
57-
58- Assert . Single ( activeMeasurements ) ;
59- Assert . Equal ( 1 , activeMeasurements [ 0 ] . Value ) ;
60- Assert . Equal ( componentType , activeMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
6154 }
6255
6356 [ Fact ]
6457 public void RenderEnd_DecreasesActiveCounterAndRecordsDuration ( )
6558 {
6659 // Arrange
6760 var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
68- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
69- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
7061 using var durationCollector = new MetricCollector < double > ( _meterFactory ,
7162 RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
7263
@@ -79,13 +70,8 @@ public void RenderEnd_DecreasesActiveCounterAndRecordsDuration()
7970 renderingMetrics . RenderEnd ( componentType , null , startTime , endTime ) ;
8071
8172 // Assert
82- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
8373 var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
8474
85- Assert . Single ( activeMeasurements ) ;
86- Assert . Equal ( - 1 , activeMeasurements [ 0 ] . Value ) ;
87- Assert . Equal ( componentType , activeMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
88-
8975 Assert . Single ( durationMeasurements ) ;
9076 Assert . True ( durationMeasurements [ 0 ] . Value > 0 ) ;
9177 Assert . Equal ( componentType , durationMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
@@ -132,14 +118,12 @@ public void IsDurationEnabled_ReturnsMeterEnabledState()
132118 }
133119
134120 [ Fact ]
135- public void FullRenderingLifecycle_RecordsAllMetricsCorrectly ( )
121+ public async Task FullRenderingLifecycle_RecordsAllMetricsCorrectly ( )
136122 {
137123 // Arrange
138124 var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
139125 using var totalCounter = new MetricCollector < long > ( _meterFactory ,
140126 RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
141- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
142- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
143127 using var durationCollector = new MetricCollector < double > ( _meterFactory ,
144128 RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
145129
@@ -152,27 +136,19 @@ public void FullRenderingLifecycle_RecordsAllMetricsCorrectly()
152136 renderingMetrics . RenderStart ( componentType ) ;
153137
154138 // 2. Component render ends
155- Thread . Sleep ( 10 ) ; // Add a small delay to ensure a measurable duration
139+ await Task . Delay ( 10 ) ; // Add a small delay to ensure a measurable duration
156140 var endTime = Stopwatch . GetTimestamp ( ) ;
157141 renderingMetrics . RenderEnd ( componentType , null , startTime , endTime ) ;
158142
159143 // Assert
160144 var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
161- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
162145 var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
163146
164147 // Total render count should have 1 measurement with value 1
165148 Assert . Single ( totalMeasurements ) ;
166149 Assert . Equal ( 1 , totalMeasurements [ 0 ] . Value ) ;
167150 Assert . Equal ( componentType , totalMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
168151
169- // Active render count should have 2 measurements (1 for start, -1 for end)
170- Assert . Equal ( 2 , activeMeasurements . Count ) ;
171- Assert . Equal ( 1 , activeMeasurements [ 0 ] . Value ) ;
172- Assert . Equal ( - 1 , activeMeasurements [ 1 ] . Value ) ;
173- Assert . Equal ( componentType , activeMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
174- Assert . Equal ( componentType , activeMeasurements [ 1 ] . Tags [ "component.type" ] ) ;
175-
176152 // Duration should have 1 measurement with a positive value
177153 Assert . Single ( durationMeasurements ) ;
178154 Assert . True ( durationMeasurements [ 0 ] . Value > 0 ) ;
@@ -186,8 +162,6 @@ public void MultipleRenders_TracksMetricsIndependently()
186162 var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
187163 using var totalCounter = new MetricCollector < long > ( _meterFactory ,
188164 RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
189- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
190- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
191165 using var durationCollector = new MetricCollector < double > ( _meterFactory ,
192166 RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
193167
@@ -215,21 +189,13 @@ public void MultipleRenders_TracksMetricsIndependently()
215189
216190 // Assert
217191 var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
218- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
219192 var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
220193
221194 // Should have 2 total render counts (one for each component)
222195 Assert . Equal ( 2 , totalMeasurements . Count ) ;
223196 Assert . Contains ( totalMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType1 ) ;
224197 Assert . Contains ( totalMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType2 ) ;
225198
226- // Should have 4 active render counts (start and end for each component)
227- Assert . Equal ( 4 , activeMeasurements . Count ) ;
228- Assert . Contains ( activeMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType1 ) ;
229- Assert . Contains ( activeMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType2 ) ;
230- Assert . Contains ( activeMeasurements , m => m . Value == - 1 && m . Tags [ "component.type" ] as string == componentType1 ) ;
231- Assert . Contains ( activeMeasurements , m => m . Value == - 1 && m . Tags [ "component.type" ] as string == componentType2 ) ;
232-
233199 // Should have 2 duration measurements (one for each component)
234200 Assert . Equal ( 2 , durationMeasurements . Count ) ;
235201 Assert . Contains ( durationMeasurements , m => m . Value > 0 && m . Tags [ "component.type" ] as string == componentType1 ) ;
0 commit comments