View Source Peep.Buckets behaviour (peep v3.5.0)

A behavior for histogram bucketing strategies.

You can pass a bucketing strategy to a distribution metric in your metrics:

def metrics do
  [
    distribution([:bandit, :request, :stop, :duration],
      tags: [],
      unit: {:native, :millisecond},
      reporter_options: [
        peep_bucket_calculator: Peep.Buckets.PowersOfTen
      ]
    )
  ]
end

If no bucketing strategy is provided is not set in :reporter_options for a %Telemetry.Metrics.Distribution{}, then the default is Peep.Buckets.Exponential.

You can change the default bucket calculator, set :bucket_calculator in your config.

config :peep, bucket_calculator: Peep.Buckets.PowersOfTen

Custom Buckets

If you want custom bucket boundaries, there is Peep.Buckets.Custom, which uses pattern matching to assign sample measurements to buckets.

Example:

defmodule MyApp.MyBucket do
  use Peep.Buckets.Custom,
    buckets: [10, 100, 1_000]
end

Summary

Types

@type config() :: map()

Callbacks

Link to this callback

bucket_for(number, config)

View Source
@callback bucket_for(number(), config()) :: non_neg_integer()
@callback config(Telemetry.Metrics.Distribution.t()) :: config()
Link to this callback

number_of_buckets(config)

View Source
@callback number_of_buckets(config()) :: pos_integer()
Link to this callback

upper_bound(non_neg_integer, config)

View Source
@callback upper_bound(non_neg_integer(), config()) :: String.t()

Functions