Merge pull request #63896 from mtaufen/refactor-test-metrics
Automatic merge from submit-queue (batch tested with PRs 64013, 63896, 64139, 57527, 62102). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Refactor test utils that deal with Kubelet metrics for clarity I found these functions hard to understand, because the names did not accurately reflect their behavior. For example, GetKubeletMetrics assumed that all of the metrics passed in were measuring latency. The caller of GetKubeletMetrics was implicitly making this assumption, but it was not obvious at the call site. ```release-note NONE ```
This commit is contained in:
@@ -319,17 +319,19 @@ func getLocalNode(f *framework.Framework) *apiv1.Node {
|
||||
return &nodeList.Items[0]
|
||||
}
|
||||
|
||||
// logs prometheus metrics from the local kubelet.
|
||||
func logKubeletMetrics(metricKeys ...string) {
|
||||
// logKubeletLatencyMetrics logs KubeletLatencyMetrics computed from the Prometheus
|
||||
// metrics exposed on the current node and identified by the metricNames.
|
||||
// The Kubelet subsystem prefix is automatically prepended to these metric names.
|
||||
func logKubeletLatencyMetrics(metricNames ...string) {
|
||||
metricSet := sets.NewString()
|
||||
for _, key := range metricKeys {
|
||||
for _, key := range metricNames {
|
||||
metricSet.Insert(kubeletmetrics.KubeletSubsystem + "_" + key)
|
||||
}
|
||||
metric, err := metrics.GrabKubeletMetricsWithoutProxy(framework.TestContext.NodeName + ":10255")
|
||||
if err != nil {
|
||||
framework.Logf("Error getting kubelet metrics: %v", err)
|
||||
} else {
|
||||
framework.Logf("Kubelet Metrics: %+v", framework.GetKubeletMetrics(metric, metricSet))
|
||||
framework.Logf("Kubelet Metrics: %+v", framework.GetKubeletLatencyMetrics(metric, metricSet))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user