Exemple #1
0
        private MetricsContextValueSource CreateValueSource(
            string context,
            GaugeValueSource gauges                     = null,
            CounterValueSource counters                 = null,
            MeterValueSource meters                     = null,
            HistogramValueSource histograms             = null,
            BucketHistogramValueSource bucketHistograms = null,
            TimerValueSource timers                     = null,
            BucketTimerValueSource bucketTimers         = null,
            ApdexValueSource apdexScores                = null)
        {
            var gaugeValues           = gauges != null ? new[] { gauges } : Enumerable.Empty <GaugeValueSource>();
            var counterValues         = counters != null ? new[] { counters } : Enumerable.Empty <CounterValueSource>();
            var meterValues           = meters != null ? new[] { meters } : Enumerable.Empty <MeterValueSource>();
            var histogramValues       = histograms != null ? new[] { histograms } : Enumerable.Empty <HistogramValueSource>();
            var bucketHistogramValues = bucketHistograms != null ? new[] { bucketHistograms } : Enumerable.Empty <BucketHistogramValueSource>();
            var timerValues           = timers != null ? new[] { timers } : Enumerable.Empty <TimerValueSource>();
            var bucketTimerValues     = bucketTimers != null ? new[] { bucketTimers } : Enumerable.Empty <BucketTimerValueSource>();
            var apdexScoreValues      = apdexScores != null ? new[] { apdexScores } : Enumerable.Empty <ApdexValueSource>();

            return(new MetricsContextValueSource(
                       context,
                       gaugeValues,
                       counterValues,
                       meterValues,
                       histogramValues,
                       bucketHistogramValues,
                       timerValues,
                       bucketTimerValues,
                       apdexScoreValues));
        }
        /// <inheritdoc />
        public bool IsBucketHistogramMatch(BucketHistogramValueSource histogram)
        {
            if (_types != null && !_types.Contains(MetricType.Histogram))
            {
                return(false);
            }

            return(IsMetricNameMatch(histogram.Name) && IsTagMatch(histogram.Tags));
        }
Exemple #3
0
        private IEnumerable <BucketHistogramValueSource> SetupBucketHistograms()
        {
            var histogramValue = new BucketHistogramValue(1, 1, new Dictionary <double, double> {
                { 1, 1 }
            });
            var histogram = new BucketHistogramValueSource(BucketHistogramNameDefault, ConstantValue.Provider(histogramValue), Unit.Items, Tags);

            return(new[] { histogram });
        }
 public static BucketHistogramMetric ToSerializableMetric(this BucketHistogramValueSource source)
 {
     return(new BucketHistogramMetric
     {
         Name = source.Name,
         Count = source.Value.Count,
         Sum = source.Value.Sum,
         Unit = source.Unit.Name,
         Buckets = source.Value.Buckets.ToDictionary(x => x.Key, x => x.Value),
         Tags = source.Tags.ToDictionary()
     });
 }
        /// <inheritdoc />
        public IBucketHistogram BucketHistogram <T>(BucketHistogramOptions options, MetricTags tags, Func <T> builder)
            where T : IBucketHistogramMetric
        {
            var allTags    = AllTags(MetricTags.Concat(options.Tags, tags));
            var metricName = allTags.AsMetricName(options.Name);

            return(_bucketHistograms.GetOrAdd(
                       metricName,
                       () =>
            {
                Logger.Trace("Adding Bucket Histogram {Name} - {@Options} {MesurementUnit} {@Tags}", metricName, options, options.MeasurementUnit.ToString(), allTags.ToDictionary());

                var histogram = builder();
                var valueSource = new BucketHistogramValueSource(
                    metricName,
                    histogram,
                    options.MeasurementUnit,
                    allTags);
                return Tuple.Create((IBucketHistogram)histogram, valueSource);
            }));
        }
Exemple #6
0
 public static IEnumerable <Metric> ToPrometheusMetrics(
     this BucketHistogramValueSource metric,
     Func <string, string> labelNameFormatter)
 {
     return(BucketHistogramValueToHistogram(metric.Value, metric.Tags, labelNameFormatter));
 }
Exemple #7
0
 public static IEnumerable <Metric> ToPrometheusMetrics(this BucketHistogramValueSource metric)
 {
     return(BucketHistogramValueToHistogram(metric.Value, metric.Tags));
 }
 /// <inheritdoc />
 public bool IsBucketHistogramMatch(BucketHistogramValueSource histogram)
 {
     return(true);
 }