Ejemplo n.º 1
0
            private protected override async Task CollectAndSerializeImplAsync(IMetricsSerializer serializer, CancellationToken cancel)
            {
                // We output sum.
                // We output count.
                // We output each bucket in order of increasing upper bound.

                await serializer.WriteMetricAsync(_sumIdentifier, _sum.Value, cancel);

                await serializer.WriteMetricAsync(_countIdentifier, _bucketCounts.Sum(b => b.Value), cancel);

                var cumulativeCount = 0L;

                for (var i = 0; i < _bucketCounts.Length; i++)
                {
                    cumulativeCount += _bucketCounts[i].Value;

                    await serializer.WriteMetricAsync(_bucketIdentifiers[i], cumulativeCount, cancel);
                }
            }
Ejemplo n.º 2
0
            private protected override async Task CollectAndSerializeImplAsync(IMetricsSerializer serializer, CancellationToken cancel)
            {
                // We output sum.
                // We output count.
                // We output quantiles.

                var now = DateTime.UtcNow;

                double count;
                double sum;
                var    values = new List <(double quantile, double value)>(_objectives.Count);

                lock (_bufLock)
                {
                    lock (_lock)
                    {
                        // Swap bufs even if hotBuf is empty to set new hotBufExpTime.
                        SwapBufs(now);
                        FlushColdBuf();

                        count = _count;
                        sum   = _sum;

                        for (var i = 0; i < _sortedObjectives.Length; i++)
                        {
                            var quantile = _sortedObjectives[i];
                            var value    = _headStream.Count == 0 ? double.NaN : _headStream.Query(quantile);

                            values.Add((quantile, value));
                        }
                    }
                }

                await serializer.WriteMetricAsync(_sumIdentifier, sum, cancel);

                await serializer.WriteMetricAsync(_countIdentifier, count, cancel);

                for (var i = 0; i < values.Count; i++)
                {
                    await serializer.WriteMetricAsync(_quantileIdentifiers[i], values[i].value, cancel);
                }
            }
Ejemplo n.º 3
0
 private protected override Task CollectAndSerializeImplAsync(IMetricsSerializer serializer, CancellationToken cancel)
 {
     return(serializer.WriteMetricAsync(_identifier, Value, cancel));
 }