@@ -52,7 +52,9 @@ func (p *PodMetricsClientImpl) FetchMetrics(
52
52
klog .Errorf ("failed to fetch metrics from %s: %v" , pod , err )
53
53
return nil , fmt .Errorf ("failed to fetch metrics from %s: %w" , pod , err )
54
54
}
55
- defer resp .Body .Close ()
55
+ defer func () {
56
+ _ = resp .Body .Close ()
57
+ }()
56
58
57
59
if resp .StatusCode != http .StatusOK {
58
60
klog .Errorf ("unexpected status code from %s: %v" , pod , resp .StatusCode )
@@ -76,17 +78,17 @@ func promToPodMetrics(
76
78
) (* backend.PodMetrics , error ) {
77
79
var errs error
78
80
updated := existing .Clone ()
79
- runningQueueSize , _ , err := getLatestMetric (metricFamilies , RunningQueueSizeMetricName )
81
+ runningQueueSize , err := getLatestMetric (metricFamilies , RunningQueueSizeMetricName )
80
82
errs = multierr .Append (errs , err )
81
83
if err == nil {
82
84
updated .RunningQueueSize = int (runningQueueSize .GetGauge ().GetValue ())
83
85
}
84
- waitingQueueSize , _ , err := getLatestMetric (metricFamilies , WaitingQueueSizeMetricName )
86
+ waitingQueueSize , err := getLatestMetric (metricFamilies , WaitingQueueSizeMetricName )
85
87
errs = multierr .Append (errs , err )
86
88
if err == nil {
87
89
updated .WaitingQueueSize = int (waitingQueueSize .GetGauge ().GetValue ())
88
90
}
89
- cachePercent , _ , err := getLatestMetric (metricFamilies , KVCacheUsagePercentMetricName )
91
+ cachePercent , err := getLatestMetric (metricFamilies , KVCacheUsagePercentMetricName )
90
92
errs = multierr .Append (errs , err )
91
93
if err == nil {
92
94
updated .KVCacheUsagePercent = cachePercent .GetGauge ().GetValue ()
@@ -151,14 +153,14 @@ func getLatestLoraMetric(metricFamilies map[string]*dto.MetricFamily) (*dto.Metr
151
153
152
154
// getLatestMetric gets the latest metric of a family. This should be used to get the latest Gauge metric.
153
155
// Since vllm doesn't set the timestamp in metric, this metric essentially gets the first metric.
154
- func getLatestMetric (metricFamilies map [string ]* dto.MetricFamily , metricName string ) (* dto.Metric , time. Time , error ) {
156
+ func getLatestMetric (metricFamilies map [string ]* dto.MetricFamily , metricName string ) (* dto.Metric , error ) {
155
157
mf , ok := metricFamilies [metricName ]
156
158
if ! ok {
157
159
klog .Warningf ("metric family %q not found" , metricName )
158
- return nil , time. Time {}, fmt .Errorf ("metric family %q not found" , metricName )
160
+ return nil , fmt .Errorf ("metric family %q not found" , metricName )
159
161
}
160
162
if len (mf .GetMetric ()) == 0 {
161
- return nil , time. Time {}, fmt .Errorf ("no metrics available for %q" , metricName )
163
+ return nil , fmt .Errorf ("no metrics available for %q" , metricName )
162
164
}
163
165
var latestTs int64
164
166
var latest * dto.Metric
@@ -169,5 +171,5 @@ func getLatestMetric(metricFamilies map[string]*dto.MetricFamily, metricName str
169
171
}
170
172
}
171
173
klog .V (4 ).Infof ("Got metric value %+v for metric %v" , latest , metricName )
172
- return latest , time . Unix ( 0 , latestTs * 1000 ), nil
174
+ return latest , nil
173
175
}
0 commit comments