Skip to content

Configure sampler intervals via environment variables

Matthias Käppler requested to merge mk/configurable-sampling-intervals into master

What does this MR do?

In !32776 (merged) we hardcoded metrics sampler intervals because we found that these settings had never been exposed to users except for the Unicorn sampler, hence most could not be changed without changing the source code. So it was found easier to just hardcode them.

However, while this simplified the code without any loss in usability, I find that it is actually useful to be able to configure these intervals, especially at development time.

What motivated the change was that for performance measurements via gpt, I needed to take Ruby GC samples more frequently than the default 60 seconds, and when testing against Omnibus, this currently requires one to edit source code in the container, which is cumbersome.

I therefore decided to add the ability to configure any sampler interval via environment keys, such as RUBY_SAMPLER_INTERVAL_SECONDS.

The configuration precedence is as follows:

  1. Any value explicitly passed through the constructor (this includes values obtained from settings files in the case of Unicorn)
  2. Any value passed through the environment
  3. The existing hard-coded constant

This makes for an override chain with sensible defaults and that is amenable to change.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Matthias Käppler

Merge request reports

Loading