예제 #1
0
        /// <summary>
        /// Generates <paramref name="count"/> count buckets, the first having the upper-incluse bound of start, others having an upper-inclusive bound that is the multiple of the previous bucket's upper-incluseive bound by <paramref name="factor"/>.
        /// An extra bucket is implicitly generated for values over the specified buckets (<see href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#histogram"/>).
        ///
        /// The generated buckets are registered to <paramref name="builder"/>.
        /// </summary>
        /// <param name="builder">The builder to assign the buckets to.</param>
        /// <param name="start">Inclusive upper bound of lowest bucket. Must be positive, non-zero, finite number.</param>
        /// <param name="factor">The factor for scaling upper-inclusive bounds of subsequent buckets. Must be finite, greater than 1.</param>
        /// <param name="count">Number of intervals create buckets for. At least 1</param>
        /// <returns>the builder supplied in <paramref name="builder"/></returns>
        public static IHistogramBuilder ExponentialBuckets(this IHistogramBuilder builder, double start, double factor, int count)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var generator = new ExponentialBucketGenerator();

            var buckets = generator.ExponentialBuckets(start, factor, count);

            builder.Buckets(buckets);

            return(builder);
        }