Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

metrics: Do not process the same map multiple times #1996

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

tpapagian
Copy link
Member

@tpapagian tpapagian commented Jan 18, 2024

For the tetragon_map_in_use_gauge metric, we iterate through sensors.AllMaps to provide their size and errors.

Depending on the sensors that are loaded and the dependencies between them, sensors.AllMaps may have the same map name multiple times. This can cause errors like:
collected metric "XXX" {...} was collected before with the same name and label values

To avoid that we keep a map and process each map only once.

Process each map only once during the calculation of tetragon_map_in_use_gauge.

@tpapagian tpapagian requested a review from a team as a code owner January 18, 2024 13:52
@tpapagian tpapagian requested a review from kevsecurity January 18, 2024 13:52
@tpapagian tpapagian added the release-note/misc This PR makes changes that have no direct user impact. label Jan 18, 2024
@tpapagian tpapagian force-pushed the pr/apapag/fix_maps_metric branch from f10f45a to fa81867 Compare January 18, 2024 13:54
For tetragon_map_in_use_gauge metric, we iterate through sensors.AllMaps
to provide their size and errors.

Depending on the sensors that are loaded and the dependencies between them,
sensors.AllMaps may have the same map name multiple times. This can cause in
errors like:
collected metric "XXX" {...} was collected before with the same name and label values

To avoid that we keep a map and we process each map only once.

Signed-off-by: Anastasios Papagiannis <[email protected]>
@tpapagian tpapagian force-pushed the pr/apapag/fix_maps_metric branch from fa81867 to 6788ed9 Compare January 18, 2024 13:58
Copy link
Member

@tixxdz tixxdz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you ;-)

Copy link
Contributor

@lambdanis lambdanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the sensors that are loaded and the dependencies between them, sensors.AllMaps may have the same map name multiple times.

Huh, I haven't realized that, thanks!

@tpapagian tpapagian merged commit 798f5b8 into main Jan 18, 2024
31 checks passed
@tpapagian tpapagian deleted the pr/apapag/fix_maps_metric branch January 18, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants