Skip to content

Commit 4004491

Browse files
authored
fix sub-second precision metric reporting (#16358)
1 parent efd0949 commit 4004491

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

pkg/autoscaler/metrics/stats_scraper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func (s *serviceScraper) Scrape(window time.Duration) (stat Stat, err error) {
226226
return
227227
}
228228
scrapeTime := s.clock.Since(startTime)
229-
scrapeTimeSec := float64(scrapeTime / time.Second)
229+
scrapeTimeSec := scrapeTime.Seconds()
230230
s.duration.Record(context.Background(), scrapeTimeSec, metric.WithAttributeSet(s.attrs))
231231
}()
232232

pkg/queue/request_metric.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package queue
1818

1919
import (
2020
"net/http"
21-
"time"
2221

2322
"go.opentelemetry.io/otel/metric"
2423
"k8s.io/utils/clock"
@@ -103,7 +102,7 @@ func (h *appRequestMetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ
103102
status = http.StatusInternalServerError
104103
}
105104

106-
elapsedTime := float64(latency / time.Second)
105+
elapsedTime := latency.Seconds()
107106
h.duration.Record(r.Context(), elapsedTime,
108107
metric.WithAttributes(semconv.HTTPResponseStatusCode(status)),
109108
)

0 commit comments

Comments
 (0)