Globally configurable bucketing strategy
Today, the default bucketing strategy is hard-coded (with a module attribute) to Peep.Buckets.Exponential. If we want to override it, we need to pass a reporter_option in each distribution (unless I'm mistaken?).
Could we have this as a top-level config item, that if unset defaults to Peep.Buckets.Exponential?
If we want to override it, we need to pass a reporter_option in each distribution (unless I'm mistaken?).
That's correct.
Could we have this as a top-level config item, that if unset defaults to Peep.Buckets.Exponential?
I think so!
Adding the option to Peep.Options is straightforward, as is validating whether the passed in module implements the Peep.Buckets behaviour when starting Peep (using function_exported?/3). The trick will be reading the configured option in Peep.Storage.Atomics.new/1, which can be called by any BEAM process. Since Peep.Storage.Atomics.new/1 is only called on the first increment to any distribution metric, one might not need to resort to something like storing a %Peep.Options in :persistent_term, and it might be acceptable to instead expose the options via a call to the Peep GenServer.
I would be happy to review and accept this as a contribution, or I could try implementing it myself when I have the bandwidth.
Thank you! I will try to see if I can implement this and push as a PR. I'm excited to contribute to this project.
Check https://github.com/rkallos/peep/pull/21 I just use Application.compile_env/3 since such configuration wouldn't change at runtime, most likely.
I would wait until people ask for such behaviour.