Ejemplo n.º 1
0
        /// <summary>
        ///     Create Histogram.
        /// </summary>
        /// <param name="name">Metric name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="buckets">Buckets.</param>
        /// <param name="options">Metric flags</param>
        /// <param name="labels">Label names</param>
        public IMetricFamily <IHistogram> CreateHistogram(string name, string help, double[] buckets = null, MetricFlags options = MetricFlags.Default, params string[] labels)
        {
            var metric = TryGetByName <IMetricFamily <IHistogram> >(name);

            if (metric == null)
            {
                var configuration = new HistogramConfiguration(name, help, labels, buckets, options);
                metric = GetHistogramFactory(labels?.Length ?? 0)(this, configuration);
            }

            ValidateLabelNames(metric.LabelNames, labels);
            return(metric);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Create Histogram.
        /// </summary>
        /// <param name="name">Metric name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="buckets">Buckets.</param>
        /// <param name="includeTimestamp">Include unix timestamp for metric.</param>
        /// <param name="labelNames">Label names</param>
        public IMetricFamily <IHistogram> CreateHistogram(string name, string help, bool includeTimestamp = false, double[] buckets = null, params string[] labelNames)
        {
            var metric = TryGetByName <IMetricFamily <IHistogram> >(name);

            if (metric == null)
            {
                var configuration = new HistogramConfiguration(name, help, labelNames, buckets, includeTimestamp);
                metric = GetHistogramFactory(labelNames?.Length ?? 0)(this, configuration);
            }
            else
            {
                ValidateLabelNames(metric.LabelNames, labelNames);
            }

            return(metric);
        }