diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs index d181fbdf9a666..aaf6cb6a20fe5 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs +++ b/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/AggregationManager.cs @@ -302,7 +302,8 @@ private void RemoveInstrumentState(Instrument instrument, InstrumentState state) { lock (this) { - return (!CheckTimeSeriesAllowed() || !CheckHistogramAllowed()) ? + // checking currentHistograms first because avoiding unexpected increment of TimeSeries count. + return (!CheckHistogramAllowed() || !CheckTimeSeriesAllowed()) ? null : new ExponentialHistogramAggregator(s_defaultHistogramConfig); }