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

[connector/servicegraphconnector] Gracefully handle half-cleaned metrics #31700

Conversation

samwright
Copy link
Contributor

The cleanCache function cleans up series that haven't been used in 15mins. It does this by:

  1. Deleting it from p.keyToMetric (which holds the dimensions for the metric), then
  2. Deleting it from all the metric series maps, e.g. p.reqTotal

In parallel, the metrics are collected by:

  1. Looping through all items in the metric series maps, e.g. p.reqTotal
  2. For each, gets the metric's dimensions from p.keyToMetric

Because these occur in opposite orders, we can get into a sticky situation where the collector function errors out when getting the metric's dimensions.

This PR reverses the order in the cleanup function, hopefully avoiding this situation.

Description:

Link to tracking Issue:

Testing:

Documentation:

The `cleanCache` function cleans up series that haven't been used in 15mins. It does this by:
1. Deleting it from p.keyToMetric (which holds the dimensions for the metric), then
2. Deleting it from all the metric series maps, e.g. p.reqTotal

In parallel, the metrics are collected by:
1. Looping through all items in the metric series maps, e.g. p.reqTotal
2. For each, gets the metric's dimensions from p.keyToMetric

Because these occur in opposite orders, we can get into a sticky situation where the collector function errors out when getting the metric's dimensions.

This PR reverses the order in the cleanup function, hopefully avoiding this situation.
Copy link
Contributor

@mapno mapno left a comment

Choose a reason for hiding this comment

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

LGTM, nice catch

@JaredTan95 JaredTan95 added the ready to merge Code review completed; ready to merge by maintainers label Mar 20, 2024
@djaglowski djaglowski merged commit 3c9a357 into open-telemetry:main Mar 26, 2024
147 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connector/servicegraph ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants