peep icon indicating copy to clipboard operation
peep copied to clipboard

Globally configurable bucketing strategy

Open aloukissas opened this issue 1 year ago • 2 comments

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?

aloukissas avatar Aug 03 '24 06:08 aloukissas

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.

rkallos avatar Aug 05 '24 16:08 rkallos

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.

aloukissas avatar Aug 05 '24 16:08 aloukissas

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.

yordis avatar Nov 10 '24 05:11 yordis