示例#1
0
        /// <summary>
        ///     Create Summary
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="options">Metric flags</param>
        /// <param name="labels">Array of label names.</param>
        /// <param name="objectives">.</param>
        /// <param name="maxAge"></param>
        /// <param name="ageBuckets"></param>
        /// <param name="bufCap"></param>
        public IMetricFamily <ISummary, TLabels> CreateSummary <TLabels>(
            string name,
            string help,
            TLabels labels,
            IReadOnlyList <QuantileEpsilonPair> objectives = null,
            TimeSpan?maxAge     = null,
            int?ageBuckets      = null,
            int?bufCap          = null,
            MetricFlags options = MetricFlags.Default)
#if HasITuple
            where TLabels : struct, ITuple, IEquatable <TLabels>
#else
            where TLabels : struct, IEquatable <TLabels>
#endif
        {
            var metric = TryGetByName <IMetricFamily <ISummary, TLabels> >(name);

            if (metric == null)
            {
                var configuration = new SummaryConfiguration(name, help, LabelsHelper.ToArray(labels), options, objectives, maxAge, ageBuckets, bufCap);
                metric = CreateSummaryInternal <TLabels>(configuration);
            }

            ValidateLabelNames(metric.LabelNames, labels);
            return(metric);
        }
示例#2
0
        /// <summary>
        ///     Create Summary
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="options">Metric flags</param>
        /// <param name="objectives">.</param>
        /// <param name="maxAge"></param>
        /// <param name="ageBuckets"></param>
        /// <param name="bufCap"></param>
        public ISummary CreateSummary(
            string name,
            string help,
            IReadOnlyList <QuantileEpsilonPair> objectives = null,
            TimeSpan?maxAge     = null,
            int?ageBuckets      = null,
            int?bufCap          = null,
            MetricFlags options = MetricFlags.Default)
        {
            var metric = TryGetByName <IMetricFamily <ISummary, ValueTuple> >(name);

            if (metric == null)
            {
                var configuration = new SummaryConfiguration(name, help, null, options, objectives, maxAge, ageBuckets, bufCap);
                metric = CreateSummaryInternal <ValueTuple>(configuration);
            }

            ValidateLabelNames(metric.LabelNames, default);
            return(metric.Unlabelled);
        }
示例#3
0
        /// <summary>
        ///     Create Summary
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="options">Metric flags</param>
        /// <param name="labels">Array of label names.</param>
        /// <param name="objectives">.</param>
        /// <param name="maxAge"></param>
        /// <param name="ageBuckets"></param>
        /// <param name="bufCap"></param>
        public IMetricFamily <ISummary> CreateSummary(
            string name,
            string help,
            IReadOnlyList <QuantileEpsilonPair> objectives = null,
            TimeSpan?maxAge     = null,
            int?ageBuckets      = null,
            int?bufCap          = null,
            MetricFlags options = MetricFlags.Default,
            params string[] labels)
        {
            var metric = TryGetByName <IMetricFamily <ISummary> >(name);

            if (metric == null)
            {
                var configuration = new SummaryConfiguration(name, help, labels, options, objectives, maxAge, ageBuckets, bufCap);
                metric = GetSummaryFactory(labels?.Length ?? 0)(this, configuration);
            }

            ValidateLabelNames(metric.LabelNames, labels);
            return(metric);
        }
示例#4
0
        /// <summary>
        ///     Create Summary
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="help">Help text.</param>
        /// <param name="includeTimestamp">Include unix timestamp for metric.</param>
        /// <param name="labelNames">Array of label names.</param>
        /// <param name="objectives">.</param>
        /// <param name="maxAge"></param>
        /// <param name="ageBuckets"></param>
        /// <param name="bufCap"></param>
        public IMetricFamily <ISummary> CreateSummary(
            string name,
            string help,
            string[] labelNames,
            bool includeTimestamp = false,
            IReadOnlyList <QuantileEpsilonPair> objectives = null,
            TimeSpan?maxAge = null,
            int?ageBuckets  = null,
            int?bufCap      = null)
        {
            var metric = TryGetByName <IMetricFamily <ISummary> >(name);

            if (metric == null)
            {
                var configuration = new SummaryConfiguration(name, help, labelNames, includeTimestamp, objectives, maxAge, ageBuckets, bufCap);
                metric = GetSummaryFactory(labelNames?.Length ?? 0)(this, configuration);
            }
            else
            {
                ValidateLabelNames(metric.LabelNames, labelNames);
            }

            return(metric);
        }
示例#5
0
 internal Summary(SummaryConfiguration configuration)
     : base(configuration)
 {
 }