示例#1
0
        /// <summary>
        /// Generates a continous series of buckets with the specified upper-inclusive bounds, with the first having a lower bound of <see cref="double.NegativeInfinity"/> and upper-incluse bound of the first item of <paramref name="bounds"/>.
        /// An extra bucket is implicitly generated for values over the specified buckets (<see href="https://prometheus.io/docs/instrumenting/writing_clientlibs/#histogram"/>).
        /// </summary>
        /// <param name="builder">The builder to assign the buckets to</param>
        /// <param name="bounds">The upper inclusive bounds of the buckets. Must be a non-empty, increasing series.</param>
        /// <returns>the builder supplied in <paramref name="builder"/></returns>
        public static ILabelledHistogramBuilder Buckets(this ILabelledHistogramBuilder builder, params double[] bounds)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            var generator = new BucketGenerator();

            var buckets = generator.Buckets(bounds);

            builder.Buckets(buckets);

            return(builder);
        }
示例#2
0
 public void Buckets_for_invalid_bounds_throws(double[] bounds)
 {
     Assert.Throws <ArgumentException>("bounds", () => generator.Buckets(bounds));
 }