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

Refactor gauge strategy #284

Merged

Conversation

Garbett1
Copy link
Contributor

@Garbett1 Garbett1 commented Mar 3, 2024

Given that the job requests are quite a hot function, and we care only about snapshots of the requests, this refactors it to use a GuageFunc to get the length of the jobs map when it's scraped.

The registering code needs to close over the server, which is the only slighy ugliness of this approach, especially needing to wrap with sync.Once otherwise the tests panic.

Name: "requests_current",
},
func() float64 {
return float64(len(srv.jobs))
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could introduce a concurrent map read / modification - if the main logic is updating it at the same time as Prometheus tries to scrape it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D'oh. Yeah, brain did not engage on that one.

@Garbett1 Garbett1 merged commit ceed86e into thought-machine:master Mar 4, 2024
5 checks passed
Hamishpk pushed a commit to Hamishpk/please-servers that referenced this pull request Mar 7, 2024
* Refactor gauge strategy to use function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants