-
Notifications
You must be signed in to change notification settings - Fork 40.6k
chore(kubelet): migrate metrics to contextual logging #130157
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
base: master
Are you sure you want to change the base?
chore(kubelet): migrate metrics to contextual logging #130157
Conversation
@@ -63,9 +63,11 @@ func (c *logMetricsCollector) DescribeWithStability(ch chan<- *metrics.Desc) { | ||
|
||
// CollectWithStability implements the metrics.StableCollector interface. | ||
func (c *logMetricsCollector) CollectWithStability(ch chan<- metrics.Metric) { | ||
podStats, err := c.podStats(context.Background()) | ||
ctx := context.Background() |
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.
ctx := context.Background() | |
ctx := context.TODO() |
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.
Thank you for your review.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zhifei92 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -68,22 +70,24 @@ func (c *criMetricsCollector) DescribeWithStability(ch chan<- *metrics.Desc) { | ||
// Collect implements the metrics.CollectWithStability interface. | ||
// TODO(haircommander): would it be better if these were processed async? | ||
func (c *criMetricsCollector) CollectWithStability(ch chan<- metrics.Metric) { | ||
podMetrics, err := c.listPodSandboxMetricsFn(context.Background()) | ||
ctx := context.TODO() |
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.
Please add a comment explaining when this should be removed.
@zhifei92 It would also make sense to look at the existing calls of the
|
Sorry for not reading the requirements document carefully. |
/triage accepted |
77c80d7
to
e87dcd1
Compare
/assign |
/retest |
e87dcd1
to
1c7e55f
Compare
@zhifei92 I can see |
Because the gomock method verifies the parameters passed to the GetCPUAndMemoryStats method (including the specific type of context), I am unsure whether to continue using Like this:
|
Can you show how it would look like with |
Even if we manage to use the same context it wouldn't help.
Can we mock context with mock.MatchedBy to make any argument implementing context.Context to match? If this is not possible, can we switch to passing logger instead of context? |
Using
|
This approach is not feasible, since it involves making substantial modifications to the existing codebase. |
1c7e55f
to
fbe6955
Compare
@zhifei92: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
migrate metrics to contextual logging
Which issue(s) this PR fixes:
Fixes #
part of #130069
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: