@@ -39,8 +39,6 @@ public void RenderStart_IncreasesCounters()
39
39
var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
40
40
using var totalCounter = new MetricCollector < long > ( _meterFactory ,
41
41
RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
42
- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
43
- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
44
42
45
43
var componentType = "TestComponent" ;
46
44
@@ -49,24 +47,17 @@ public void RenderStart_IncreasesCounters()
49
47
50
48
// Assert
51
49
var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
52
- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
53
50
54
51
Assert . Single ( totalMeasurements ) ;
55
52
Assert . Equal ( 1 , totalMeasurements [ 0 ] . Value ) ;
56
53
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" ] ) ;
61
54
}
62
55
63
56
[ Fact ]
64
57
public void RenderEnd_DecreasesActiveCounterAndRecordsDuration ( )
65
58
{
66
59
// Arrange
67
60
var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
68
- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
69
- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
70
61
using var durationCollector = new MetricCollector < double > ( _meterFactory ,
71
62
RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
72
63
@@ -79,13 +70,8 @@ public void RenderEnd_DecreasesActiveCounterAndRecordsDuration()
79
70
renderingMetrics . RenderEnd ( componentType , null , startTime , endTime ) ;
80
71
81
72
// Assert
82
- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
83
73
var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
84
74
85
- Assert . Single ( activeMeasurements ) ;
86
- Assert . Equal ( - 1 , activeMeasurements [ 0 ] . Value ) ;
87
- Assert . Equal ( componentType , activeMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
88
-
89
75
Assert . Single ( durationMeasurements ) ;
90
76
Assert . True ( durationMeasurements [ 0 ] . Value > 0 ) ;
91
77
Assert . Equal ( componentType , durationMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
@@ -132,14 +118,12 @@ public void IsDurationEnabled_ReturnsMeterEnabledState()
132
118
}
133
119
134
120
[ Fact ]
135
- public void FullRenderingLifecycle_RecordsAllMetricsCorrectly ( )
121
+ public async Task FullRenderingLifecycle_RecordsAllMetricsCorrectly ( )
136
122
{
137
123
// Arrange
138
124
var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
139
125
using var totalCounter = new MetricCollector < long > ( _meterFactory ,
140
126
RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
141
- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
142
- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
143
127
using var durationCollector = new MetricCollector < double > ( _meterFactory ,
144
128
RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
145
129
@@ -152,27 +136,19 @@ public void FullRenderingLifecycle_RecordsAllMetricsCorrectly()
152
136
renderingMetrics . RenderStart ( componentType ) ;
153
137
154
138
// 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
156
140
var endTime = Stopwatch . GetTimestamp ( ) ;
157
141
renderingMetrics . RenderEnd ( componentType , null , startTime , endTime ) ;
158
142
159
143
// Assert
160
144
var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
161
- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
162
145
var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
163
146
164
147
// Total render count should have 1 measurement with value 1
165
148
Assert . Single ( totalMeasurements ) ;
166
149
Assert . Equal ( 1 , totalMeasurements [ 0 ] . Value ) ;
167
150
Assert . Equal ( componentType , totalMeasurements [ 0 ] . Tags [ "component.type" ] ) ;
168
151
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
-
176
152
// Duration should have 1 measurement with a positive value
177
153
Assert . Single ( durationMeasurements ) ;
178
154
Assert . True ( durationMeasurements [ 0 ] . Value > 0 ) ;
@@ -186,8 +162,6 @@ public void MultipleRenders_TracksMetricsIndependently()
186
162
var renderingMetrics = new RenderingMetrics ( _meterFactory ) ;
187
163
using var totalCounter = new MetricCollector < long > ( _meterFactory ,
188
164
RenderingMetrics . MeterName , "aspnetcore.components.rendering.count" ) ;
189
- using var activeCounter = new MetricCollector < long > ( _meterFactory ,
190
- RenderingMetrics . MeterName , "aspnetcore.components.rendering.active_renders" ) ;
191
165
using var durationCollector = new MetricCollector < double > ( _meterFactory ,
192
166
RenderingMetrics . MeterName , "aspnetcore.components.rendering.duration" ) ;
193
167
@@ -215,21 +189,13 @@ public void MultipleRenders_TracksMetricsIndependently()
215
189
216
190
// Assert
217
191
var totalMeasurements = totalCounter . GetMeasurementSnapshot ( ) ;
218
- var activeMeasurements = activeCounter . GetMeasurementSnapshot ( ) ;
219
192
var durationMeasurements = durationCollector . GetMeasurementSnapshot ( ) ;
220
193
221
194
// Should have 2 total render counts (one for each component)
222
195
Assert . Equal ( 2 , totalMeasurements . Count ) ;
223
196
Assert . Contains ( totalMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType1 ) ;
224
197
Assert . Contains ( totalMeasurements , m => m . Value == 1 && m . Tags [ "component.type" ] as string == componentType2 ) ;
225
198
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
-
233
199
// Should have 2 duration measurements (one for each component)
234
200
Assert . Equal ( 2 , durationMeasurements . Count ) ;
235
201
Assert . Contains ( durationMeasurements , m => m . Value > 0 && m . Tags [ "component.type" ] as string == componentType1 ) ;
0 commit comments