Exemplo n.º 1
0
        Task OnTick()
        {
            try
            {
                Queue <PointData> batch;
                lock (_queueLock)
                {
                    if (_queue.Count == 0)
                    {
                        return(Task.Delay(0));
                    }

                    batch  = _queue;
                    _queue = new Queue <PointData>();
                }

                _parent.Emit(batch.ToArray());
            }
            catch (Exception ex)
            {
                CollectorLog.ReportError("Failed to emit metrics batch", ex);
            }
            finally
            {
                lock (_stateLock)
                {
                    if (!_unloading)
                    {
                        _timer.Start(_interval);
                    }
                }
            }

            return(Task.Delay(0));
        }
Exemplo n.º 2
0
        void OnTick()
        {
            try
            {
                Queue <PointData> batch;
                lock (_queueLock)
                {
                    if (_queue.Count == 0)
                    {
                        return;
                    }

                    batch  = _queue;
                    _queue = new Queue <PointData>();
                }

                _parent.Emit(batch.ToArray());
            }
            catch (Exception ex)
            {
                CollectorLog.WriteLine("Failed to emit metrics batch: {0}", ex);
            }
            finally
            {
                lock (_stateLock)
                {
                    if (!_unloading)
                    {
                        _timer.Start(_interval);
                    }
                }
            }
        }
        Task OnTick()
        {
            try
            {
                Queue <PointData> batch;
                lock (_queueLock)
                {
                    if (_queue.Count == 0)
                    {
                        return(Task.Delay(0));
                    }

                    batch  = _queue;
                    _queue = new Queue <PointData>();
                }

                if (_maxBatchSize == null || batch.Count <= _maxBatchSize.Value)
                {
                    _parent.Emit(batch.ToArray());
                }
                else
                {
                    foreach (var chunk in batch.Batch(_maxBatchSize.Value))
                    {
                        _parent.Emit(chunk.ToArray());
                    }
                }
            }
            catch (Exception ex)
            {
                CollectorLog.ReportError("Failed to emit metrics batch", ex);
            }
            finally
            {
                lock (_stateLock)
                {
                    if (!_unloading)
                    {
                        _timer.Start(_interval);
                    }
                }
            }

            return(Task.Delay(0));
        }
        protected override void Emit(PointData[] points)
        {
            foreach (var point in points)
            {
                _enricher.Enrich(point);
            }

            _emitter.Emit(points);
        }