Пример #1
0
        /// <inheritdoc />
        public TimerValue GetValue(bool resetMetric = false)
        {
            var total = resetMetric ? _totalRecordedTime.GetAndReset() : _totalRecordedTime.GetValue();

            return(new TimerValue(_meter.GetValue(resetMetric), _histogram.GetValue(resetMetric), _activeSessionsCounter.GetValue(), total,
                                  TimeUnit.Nanoseconds));
        }
Пример #2
0
        public void Can_get_and_reset()
        {
            _num.Add(32);
            var val = _num.GetAndReset();

            val.Should().Be(32);
            _num.GetValue().Should().Be(0);
        }
 public void StripedLongAdder()
 {
     _stripedLongAdder.Increment();
     _stripedLongAdder.Decrement();
     _stripedLongAdder.GetAndReset();
     _stripedLongAdder.NonVolatileGetValue();
     _stripedLongAdder.Increment();
     _stripedLongAdder.Decrement();
 }
Пример #4
0
        private void StatsAction()
        {
            try
            {
                long now     = DateTime.Now.Millisecond;
                var  elapsed = (now - OldTime) / 1e9;
                _oldTime = now;

                var currentNumMsgsSent       = _numMsgsSent.GetAndReset();
                var currentNumBytesSent      = _numBytesSent.GetAndReset();
                var currentNumSendFailedMsgs = _numSendFailed.GetAndReset();
                var currentNumAcksReceived   = _numAcksReceived.GetAndReset();

                _totalMsgsSent.Add(currentNumMsgsSent);
                _totalBytesSent.Add(currentNumBytesSent);
                _totalSendFailed.Add(currentNumSendFailedMsgs);
                _totalAcksReceived.Add(currentNumAcksReceived);

                lock (Latency)
                {
                    _latencyPctValues = GetQuantiles(Percentiles);
                    Latency           = new List <double>(256);
                }

                SendMsgsRate  = currentNumMsgsSent / elapsed;
                SendBytesRate = currentNumBytesSent / elapsed;

                if ((currentNumMsgsSent | currentNumSendFailedMsgs | currentNumAcksReceived | currentNumMsgsSent) !=
                    0)
                {
                    for (var i = 0; i < _latencyPctValues.Length; i++)
                    {
                        if (double.IsNaN(_latencyPctValues[i]))
                        {
                            _latencyPctValues[i] = 0;
                        }
                    }

                    _log.Info(
                        $"[{_topic}] [{_producerName}] Pending messages: {_pendingQueueSize} --- Publish throughput: {SendMsgsRate.ToString(ThroughputFormat)} msg/s --- {(SendBytesRate / 1024 / 1024 * 8).ToString(ThroughputFormat)} Mbit/s --- " +
                        $"Latency: med: {(_latencyPctValues[0] / 1000.0).ToString(Dec)} ms - 95pct: {(_latencyPctValues[2] / 1000.0).ToString(Dec)} ms - 99pct: {(_latencyPctValues[3] / 1000.0).ToString(Dec)} ms - 99.9pct: {(_latencyPctValues[4] / 1000.0).ToString(Dec)} ms - max: {(_latencyPctValues[5] / 1000.0).ToString(Dec)} ms --- " +
                        $"Ack received rate: {(currentNumAcksReceived / elapsed).ToString(ThroughputFormat)} ack/s --- Failed messages: {currentNumSendFailedMsgs}");
                }
            }
            catch (Exception e)
            {
                _log.Error("[{}] [{}]: {}", _topic, _producerName, e.Message);
            }
            finally
            {
                // schedule the next stat info
                StatTimeout = _system.Scheduler.Advanced.ScheduleOnceCancelable(TimeSpan.FromSeconds(_statsIntervalSeconds), StatsAction);
            }
        }
Пример #5
0
        /// <inheritdoc />
        public TimerValue GetValue(bool resetMetric = false)
        {
            var activeSessions = resetMetric
                ? _activeSessionsCounter.GetAndReset()
                : _activeSessionsCounter.GetValue();

            return(new TimerValue(
                       _meter.GetValue(resetMetric),
                       _histogram.GetValue(resetMetric),
                       activeSessions,
                       TimeUnit.Nanoseconds));
        }
Пример #6
0
        private void StatsAction()
        {
            try
            {
                long now     = DateTime.Now.Millisecond;
                var  elapsed = (now - OldTime) / 1e9;
                _oldTime = now;
                var currentNumMsgsReceived       = _numMsgsReceived.GetAndReset();
                var currentNumBytesReceived      = _numBytesReceived.GetAndReset();
                var currentNumReceiveFailed      = _numReceiveFailed.GetAndReset();
                var currentNumBatchReceiveFailed = _numBatchReceiveFailed.GetAndReset();
                var currentNumAcksSent           = _numAcksSent.GetAndReset();
                var currentNumAcksFailed         = _numAcksFailed.GetAndReset();

                _totalMsgsReceived.Add(currentNumMsgsReceived);
                _totalBytesReceived.Add(currentNumBytesReceived);
                _totalReceiveFailed.Add(currentNumReceiveFailed);
                _totalBatchReceiveFailed.Add(currentNumBatchReceiveFailed);
                _totalAcksSent.Add(currentNumAcksSent);
                _totalAcksFailed.Add(currentNumAcksFailed);

                RateMsgsReceived  = currentNumMsgsReceived / elapsed;
                RateBytesReceived = currentNumBytesReceived / elapsed;

                if ((currentNumMsgsReceived | currentNumBytesReceived | currentNumReceiveFailed | currentNumAcksSent | currentNumAcksFailed) != 0)
                {
                    _log.Info($"[{_topic}] [{_subscription}] [{_name}] Consume throughput received: {(RateMsgsReceived).ToString(ThroughputFormat)} msgs/s --- {(RateBytesReceived * 8 / 1024 / 1024).ToString(ThroughputFormat)} Mbit/s --- Ack sent rate: {(currentNumAcksSent / elapsed).ToString(ThroughputFormat)} ack/s --- Failed messages: {currentNumReceiveFailed} --- batch messages: {currentNumBatchReceiveFailed} ---Failed acks: {currentNumAcksFailed}");
                }
            }
            catch (Exception e)
            {
                _log.Error($"[{_topic}] [{_name}] [{_subscription}]: {e.Message}");
            }
            finally
            {
                // schedule the next stat info
                _statTimeout = _system.Scheduler.Advanced.ScheduleOnceCancelable(TimeSpan.FromSeconds(_statsIntervalSeconds), StatsAction);
            }
        }
Пример #7
0
        public void Tick()
        {
            var count = _uncounted.GetAndReset();

            Tick(count);
        }