-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[prebuilds] increment metric only with state change #10621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The links in the 'How to test' section don't work for me. Here's what I did:
- Set my kube context to your preview environment.
- Port forwarded to the
prometheus-k8s
service. - Made an SSH tunnel from my local machine to my workspace so I could access prometheus at localhost.
- Started a few prebuilds and watched the
gitpod_prebuilds_started_total
andgitpod_prebuilds_completed_total
metrics in the prometheus UI.
Things look basically ok to me; for every prebuild I started I saw the started
counter increase, and when it completed I saw completed
increase.
The counter for the prebuild start increased when the imagebuild was started though, not exactly when the prebuild started. Not sure if this is desired behaviour.
@andrew-farries Sorry this was probably because my workspace timed out. Thanks for managing to test despite it!
The increment should happen once we've stored a prebuilt workspace with a |
f5429ef
to
c242593
Compare
c242593
to
ff6d055
Compare
@@ -80,7 +80,15 @@ export class PrebuildUpdaterDB implements PrebuildUpdater { | |||
span.setTag("updatePrebuildWorkspace.prebuild.state", updatedPrebuild.state); | |||
span.setTag("updatePrebuildWorkspace.prebuild.error", updatedPrebuild.error); | |||
|
|||
if (writeToDB && updatedPrebuild.state && terminatingStates.includes(updatedPrebuild.state)) { | |||
// Here we make sure that we increment the counter only when: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, code LGTM, thx for the comments and logCtx fixex! 🙏
Description
This PR makes sure that metrics are only incremented when a prebuild state changes.
It also extends the logging information with the logging context.
Related Issue(s)
Fixes #10616
How to test
started
andcompleted
.Release Notes
Documentation