promgleam/buckets

Utility functions to generate buckets for Histogram metrics.

Types

pub type Buckets =
  List(Float)

Functions

pub fn exponential(
  start start: Float,
  factor factor: Int,
  count count: Int,
) -> Result(List(Float), String)

Creates count buckets, where the lowest bucket has an upper bound of start and each following bucket’s upper bound is factor times the previous bucket’s upper bound.

Examples

let assert Ok([1.0, 2.0, 4.0, 8.0]) = exponential(start: 1.0, factor: 2, count: 4)
pub fn linear(
  start start: Float,
  step step: Float,
  count count: Int,
) -> Result(List(Float), String)

Creates count buckets, each step wide, where the lowest bucket has an upper bound of start.

Examples

let assert Ok([1.0, 4.0, 7.0, 10.0]) = linear(start: 1.0, step: 3.0, count: 4)
Search Document