public void Count(string counterName, long rawValue) { try { if (_counters.ContainsKey(counterName)) { PerfData perfData = _counters[counterName]; if (perfData.Counter != null) { perfData.Counter.RawValue = rawValue; if (perfData.Max == null || rawValue > perfData.Max) { perfData.Max = rawValue; } if (perfData.Min == null || rawValue < perfData.Min) { perfData.Min = rawValue; } } } } catch (Exception ex) { Log.Default.Error(ex); } }
internal float Sample(string counterName) { PerfData perfData = _counters[counterName]; return(perfData != null ? CounterSample.Calculate(perfData.Samples[0], perfData.Counter.NextSample()) : 0); }
/// <param name="getNextSample">is needed for all history storing /// buy may occupy too many resources</param> /// <returns></returns> private long Count(string counterName, bool getNextSample) { try { if (_counters.ContainsKey(counterName)) { PerfData perfData = _counters[counterName]; if (perfData.Counter != null) { long?v = perfData.Max = perfData.Counter.Increment(); if (getNextSample) { perfData.Samples.Add(perfData.Counter.NextSample()); } return((long)v); } } } catch (Exception ex) { Log.Default.Error(ex); } return(0); }