-
Notifications
You must be signed in to change notification settings - Fork 24
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
reporting repository provision request times to prometheus for SLO/SLI #84
Conversation
imageRepositoryProvisionTimeMetric.Observe(time.Since(provisionTime).Seconds()) | ||
} | ||
// remove component from metrics map | ||
delete(repositoryTimesForMetrics, componentIdForMetrics) |
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.
We can do the deletion only if the time was recorded.
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.
time will be always recorded at that point
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.
Then why do we need that if
above?
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.
I need real time for observe, I don't have to check that something is in map when removing
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.
I mean in this case I guess I can just move that delete inside if
769fb70
to
c3d7e41
Compare
|
||
func getComponentIdForMetrics(component *appstudioredhatcomv1alpha1.Component) string { | ||
return component.Name + "=" + component.Namespace | ||
} |
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 is duplicate code at line https://github.com/redhat-appstudio/image-controller/pull/84/files#diff-922fcbfbe2565443329918a2b0d49b2b03588007ec6464a20d3feb824f3f80a2R143
I'd suggest to simplify the arguments and make them explicit
func getComponentIdForMetrics(componentName, componentNS string) string {
}
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.
well that uses different thing and not component
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.
Function initMetrics
is called twice inside both reconciler SetupWithManager
functions. I assume the duplicated calls should not cause any potential problem due to the underlying package handles that. Even though, how about to avoid duplicated call explicitly?
Metrics related code are mainly implemented inside imagerepository_controller.go file and shared with ComponentReconciler. My suggestion is to make a separate go file under package controllers
to include those shared code related to metrics.
@@ -90,7 +151,12 @@ func (r *ImageRepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
componentIdForMetrics := fmt.Sprintf("%s=%s", imageRepository.Labels[ComponentNameLabelName], imageRepository.Namespace) |
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.
ImageRepository doesn't have to have ComponentNameLabelName
label. For example, JBS uses it without the label.
I think we have to have identifier not related to Component, but to instance of ImageRepository itself.
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.
will use name + namespace then
did you see the first thing I do in initMetrics??
that ensures it doesn't run multiple times but I have to call it in both controllers because 1 of them will be first to initialize it |
100872f
to
3704627
Compare
STONEBLD-1775 Signed-off-by: Robert Cerven <[email protected]>
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
/retest |
STONEBLD-1775