Exemplo n.º 1
0
        private void Consumer()
        {
            _logger?.LogInformation($"Start {Name}.");

            _status = true;

            while (!_cancellationTokenSource.IsCancellationRequested)
            {
                ProcessQueue();

                try
                {
                    _eventSlim.Wait(_cancellationTokenSource.Token);
                    _eventSlim.Reset();
                }
                catch (OperationCanceledException ex)
                {
                    // expected
                    _logger?.LogError("AsyncQueueDispatcher exception.", ex);
                    break;
                }
            }

            ProcessQueue(); // one last time for the remaining messages
        }
Exemplo n.º 2
0
        public bool Start()
        {
            if (Interlocked.CompareExchange(ref _status, 0, 1) == 1)
            {
                _payloadDispatcher.Start();
                foreach (var profilerSetup in _profilerSetups)
                {
                    profilerSetup.Start();
                }
                _logger?.LogInformation($"AspectCore APM started.");
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public LineProtocolPayloadClient(LineProtocolClientOptions lineProtocolClientOptions, IInternalLogger logger = null)
        {
            _logger = logger;
            _lineProtocolClientOptions = lineProtocolClientOptions ?? throw new ArgumentNullException(nameof(lineProtocolClientOptions));
            _lineProtocolClient        = new InternalLineProtocolClient(
                _lineProtocolClientOptions.Server, _lineProtocolClientOptions.Database,
                _lineProtocolClientOptions.UserName, _lineProtocolClientOptions.Password);
            var interval = lineProtocolClientOptions.Interval.HasValue && lineProtocolClientOptions.Interval.Value > 0 ? lineProtocolClientOptions.Interval.Value : _defaultInterval;

            _blockCapacity = lineProtocolClientOptions.BlockCapacity.GetValueOrDefault(_defaultBlockCapacity);
            _pointMap      = new ConcurrentDictionary <PointState, object>();
            _flushTimer    = new Timer(async state => await FlushCallback(state), null, TimeSpan.FromSeconds(interval), TimeSpan.FromSeconds(interval));
            _logger?.LogInformation("Start LineProtocolCollector.");
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     _flushTimer.Dispose();
     _logger?.LogInformation("Stop LineProtocolCollector.");
 }
Exemplo n.º 5
0
 public bool Start()
 {
     _callbackTimer = new Timer(async state => await Callback(state), null, TimeSpan.FromSeconds(_interval), TimeSpan.FromSeconds(_interval));
     _logger?.LogInformation("Start ApplicationProfiler.");
     return(true);
 }