Skip to content

Commit 4a579c2

Browse files
authored
chore: add help func for get Env value (vllm-project#941)
Signed-off-by: googs1025 <[email protected]>
1 parent 8a1a3a1 commit 4a579c2

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

pkg/cache/cache_metrics.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package cache
1818
import (
1919
"context"
2020
"fmt"
21-
"strconv"
2221
"time"
2322

2423
prometheusv1 "github.com/prometheus/client_golang/api/prometheus/v1"
@@ -75,8 +74,7 @@ var (
7574
metrics.WaitingLoraAdapters,
7675
metrics.RunningLoraAdapters,
7776
}
78-
// TODO: add a helper function for get methods.
79-
podMetricRefreshInterval = getPodMetricRefreshInterval()
77+
podMetricRefreshInterval = time.Duration(utils.LoadEnvInt("AIBRIX_POD_METRIC_REFRESH_INTERVAL_MS", defaultPodMetricRefreshIntervalInMS)) * time.Millisecond
8078
)
8179

8280
func initPrometheusAPI() prometheusv1.API {
@@ -99,21 +97,6 @@ func initPrometheusAPI() prometheusv1.API {
9997
return prometheusApi
10098
}
10199

102-
func getPodMetricRefreshInterval() time.Duration {
103-
value := utils.LoadEnv("AIBRIX_POD_METRIC_REFRESH_INTERVAL_MS", "")
104-
if value != "" {
105-
intValue, err := strconv.Atoi(value)
106-
if err != nil || intValue <= 0 {
107-
klog.Infof("invalid AIBRIX_POD_METRIC_REFRESH_INTERVAL_MS: %s, falling back to default", value)
108-
} else {
109-
klog.Infof("using AIBRIX_POD_METRIC_REFRESH_INTERVAL_MS env value for pod metrics refresh interval: %d ms", intValue)
110-
return time.Duration(intValue) * time.Millisecond
111-
}
112-
}
113-
klog.Infof("using default refresh interval: %d ms", defaultPodMetricRefreshIntervalInMS)
114-
return defaultPodMetricRefreshIntervalInMS * time.Millisecond
115-
}
116-
117100
func (c *Store) getPodMetricImpl(podName string, metricStore *utils.SyncMap[string, metrics.MetricValue], metricName string) (metrics.MetricValue, error) {
118101
metricVal, ok := metricStore.Load(metricName)
119102
if !ok {

0 commit comments

Comments
 (0)