Configure sampler intervals via environment variables
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:
- Any value explicitly passed through the constructor (this includes values obtained from settings files in the case of Unicorn)
- Any value passed through the environment
- 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
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done