Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

metrics: Refactor metrics label filter logic #2373

Conversation

lambdanis
Copy link
Contributor

Another little refactoring of the metrics label filter logic. The idea behind it is that we can have multiple groups of configurable labels, each one with defaults and helper functions for creating a labels struct. I reorganized the code a bit to enable easy creation of different groups of labels, configurable with different options. Notable changes:

  • Default label filter is now returned by DefaultLabelsFilter function in pkg/option instead of defining a global variable in pkg/metrics/consts. This is to prevent accidentally mutating the default.
  • When updating a metric with configurable labels we use CreateProcessLabels function from pkg/option. Arguably putting it in the option package is not perfect, but the metrics package shouldn't depend on option and I didn't want to introduce a separate package at this stage.

@lambdanis lambdanis added area/metrics Related to prometheus metrics release-note/misc This PR makes changes that have no direct user impact. labels Apr 24, 2024
@lambdanis lambdanis requested a review from a team as a code owner April 24, 2024 19:37
@lambdanis lambdanis requested a review from willfindlay April 24, 2024 19:37
Another little refactoring of the metrics label filter logic. The idea behind
it is that we can have multiple groups of configurable labels, each one with
defaults and helper functions for creating a labels struct. I reorganized the
code a bit to enable easy creation of different groups of labels, configurable
with different options. Notable changes:
* Default label filter is now returned by DefaultLabelsFilter function in
  pkg/option instead of defining a global variable in pkg/metrics/consts. This
  is to prevent accidentally mutating the default.
* When updating a metric with configurable labels we use CreateProcessLabels
  function from pkg/option. Arguably putting it in the option package is not
  perfect, but the metrics package shouldn't depend on option and I didn't want
  to introduce a separate package at this stage.

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
@lambdanis lambdanis force-pushed the pr/lambdanis/metrics-labels-little-refactoring branch from c988972 to 52475e7 Compare April 24, 2024 19:52
@lambdanis lambdanis merged commit ebbab4e into cilium:main Apr 25, 2024
33 checks passed
@lambdanis lambdanis changed the title Refactor metrics label filter logic metrics: Refactor metrics label filter logic Apr 26, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area/metrics Related to prometheus metrics release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants