@@ -52,7 +52,9 @@ func (p *PodMetricsClientImpl) FetchMetrics(
5252 klog .Errorf ("failed to fetch metrics from %s: %v" , pod , err )
5353 return nil , fmt .Errorf ("failed to fetch metrics from %s: %w" , pod , err )
5454 }
55- defer resp .Body .Close ()
55+ defer func () {
56+ _ = resp .Body .Close ()
57+ }()
5658
5759 if resp .StatusCode != http .StatusOK {
5860 klog .Errorf ("unexpected status code from %s: %v" , pod , resp .StatusCode )
@@ -76,17 +78,17 @@ func promToPodMetrics(
7678) (* backend.PodMetrics , error ) {
7779 var errs error
7880 updated := existing .Clone ()
79- runningQueueSize , _ , err := getLatestMetric (metricFamilies , RunningQueueSizeMetricName )
81+ runningQueueSize , err := getLatestMetric (metricFamilies , RunningQueueSizeMetricName )
8082 errs = multierr .Append (errs , err )
8183 if err == nil {
8284 updated .RunningQueueSize = int (runningQueueSize .GetGauge ().GetValue ())
8385 }
84- waitingQueueSize , _ , err := getLatestMetric (metricFamilies , WaitingQueueSizeMetricName )
86+ waitingQueueSize , err := getLatestMetric (metricFamilies , WaitingQueueSizeMetricName )
8587 errs = multierr .Append (errs , err )
8688 if err == nil {
8789 updated .WaitingQueueSize = int (waitingQueueSize .GetGauge ().GetValue ())
8890 }
89- cachePercent , _ , err := getLatestMetric (metricFamilies , KVCacheUsagePercentMetricName )
91+ cachePercent , err := getLatestMetric (metricFamilies , KVCacheUsagePercentMetricName )
9092 errs = multierr .Append (errs , err )
9193 if err == nil {
9294 updated .KVCacheUsagePercent = cachePercent .GetGauge ().GetValue ()
@@ -151,14 +153,14 @@ func getLatestLoraMetric(metricFamilies map[string]*dto.MetricFamily) (*dto.Metr
151153
152154// getLatestMetric gets the latest metric of a family. This should be used to get the latest Gauge metric.
153155// 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 ) {
155157 mf , ok := metricFamilies [metricName ]
156158 if ! ok {
157159 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 )
159161 }
160162 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 )
162164 }
163165 var latestTs int64
164166 var latest * dto.Metric
@@ -169,5 +171,5 @@ func getLatestMetric(metricFamilies map[string]*dto.MetricFamily, metricName str
169171 }
170172 }
171173 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
173175}
0 commit comments