File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ internal sealed class CounterGroup
1717 private readonly EventSource _eventSource ;
1818 private readonly List < DiagnosticCounter > _counters ;
1919 private static readonly object s_counterGroupLock = new object ( ) ;
20+ private bool _resetCounters = true ;
2021
2122 internal CounterGroup ( EventSource eventSource )
2223 {
@@ -155,7 +156,6 @@ private void EnableTimer(float pollingIntervalInSeconds)
155156 if ( _pollingIntervalInMilliseconds == 0 || pollingIntervalInSeconds * 1000 < _pollingIntervalInMilliseconds )
156157 {
157158 _pollingIntervalInMilliseconds = ( int ) ( pollingIntervalInSeconds * 1000 ) ;
158- ResetCounters ( ) ; // Reset statistics for counters before we start the thread.
159159
160160 _timeStampSinceCollectionStarted = DateTime . UtcNow ;
161161 _nextPollingTimeStamp = DateTime . UtcNow + new TimeSpan ( 0 , 0 , ( int ) pollingIntervalInSeconds ) ;
@@ -223,6 +223,12 @@ private void OnTimer()
223223 DiagnosticCounter [ ] counters ;
224224 lock ( s_counterGroupLock )
225225 {
226+ if ( _resetCounters )
227+ {
228+ ResetCounters ( ) ;
229+ _resetCounters = false ;
230+ }
231+
226232 now = DateTime . UtcNow ;
227233 elapsed = now - _timeStampSinceCollectionStarted ;
228234 pollingIntervalInMilliseconds = _pollingIntervalInMilliseconds ;
You can’t perform that action at this time.
0 commit comments