public GCEventsListener()
 {
     _collectionCountPerGen = new InterlockedCounter[GC.MaxGeneration + 1];
     for (var i = 0; i < _collectionCountPerGen.Length; i++)
     {
         _collectionCountPerGen[i] = new InterlockedCounter();
     }
 }
        private bool TryGetCount(InterlockedCounter counter, out int metricCount)
        {
            metricCount = 0;
            if (counter.Value > 0)
            {
                metricCount = counter.Exchange(0);
                return(true);
            }

            return(false);
        }
        static ApiSupportabilityMetricCounters()
        {
            var values = Enum.GetValues(typeof(ApiMethod));

            MetricNames = new string[values.Length];
            Counters    = new InterlockedCounter[values.Length];
            foreach (var value in values)
            {
                MetricNames[(int)value] = Enum.GetName(typeof(ApiMethod), value);
                Counters[(int)value]    = new InterlockedCounter();
            }
        }
Beispiel #4
0
        public AgentHealthReporter(IMetricBuilder metricBuilder, IScheduler scheduler, IDnsStatic dnsStatic)
        {
            _metricBuilder = metricBuilder;
            _dnsStatic     = dnsStatic;
            _scheduler     = scheduler;
            _scheduler.ExecuteEvery(LogRecurringLogs, _timeBetweenExecutions);
            var agentHealthEvents = Enum.GetValues(typeof(AgentHealthEvent)) as AgentHealthEvent[];

            foreach (var agentHealthEvent in agentHealthEvents)
            {
                _agentHealthEventCounters[agentHealthEvent] = new InterlockedCounter();
            }

            _payloadCreateSuccessCounter      = new InterlockedCounter();
            _payloadAcceptSuccessCounter      = new InterlockedCounter();
            _traceContextAcceptSuccessCounter = new InterlockedCounter();
            _traceContextCreateSuccessCounter = new InterlockedCounter();
        }