Skip to content

Commit ab18255

Browse files
committed
clean SinceInMicroseconds, convert to SinceInSeconds
1 parent a8f2fea commit ab18255

File tree

9 files changed

+2
-56
lines changed

9 files changed

+2
-56
lines changed

pkg/kubelet/dockershim/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ func Register() {
9696
})
9797
}
9898

99-
// SinceInMicroseconds gets the time since the specified start in microseconds.
100-
func SinceInMicroseconds(start time.Time) float64 {
101-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
102-
}
103-
10499
// SinceInSeconds gets the time since the specified start in seconds.
105100
func SinceInSeconds(start time.Time) float64 {
106101
return time.Since(start).Seconds()

pkg/kubelet/dockershim/network/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ func Register() {
5858
})
5959
}
6060

61-
// SinceInMicroseconds gets the time since the specified start in microseconds.
62-
func SinceInMicroseconds(start time.Time) float64 {
63-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
64-
}
65-
6661
// SinceInSeconds gets the time since the specified start in seconds.
6762
func SinceInSeconds(start time.Time) float64 {
6863
return time.Since(start).Seconds()

pkg/kubelet/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,6 @@ func GetGather() metrics.Gatherer {
409409
return legacyregistry.DefaultGatherer
410410
}
411411

412-
// SinceInMicroseconds gets the time since the specified start in microseconds.
413-
func SinceInMicroseconds(start time.Time) float64 {
414-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
415-
}
416-
417412
// SinceInSeconds gets the time since the specified start in seconds.
418413
func SinceInSeconds(start time.Time) float64 {
419414
return time.Since(start).Seconds()

pkg/proxy/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ func RegisterMetrics() {
143143
})
144144
}
145145

146-
// SinceInMicroseconds gets the time since the specified start in microseconds.
147-
func SinceInMicroseconds(start time.Time) float64 {
148-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
149-
}
150-
151146
// SinceInSeconds gets the time since the specified start in seconds.
152147
func SinceInSeconds(start time.Time) float64 {
153148
return time.Since(start).Seconds()

pkg/scheduler/metrics/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,6 @@ func Reset() {
290290
DeprecatedSchedulingDuration.Reset()
291291
}
292292

293-
// SinceInMicroseconds gets the time since the specified start in microseconds.
294-
func SinceInMicroseconds(start time.Time) float64 {
295-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
296-
}
297-
298293
// SinceInSeconds gets the time since the specified start in seconds.
299294
func SinceInSeconds(start time.Time) float64 {
300295
return time.Since(start).Seconds()

staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ func MonitorRequest(req *http.Request, verb, group, version, resource, subresour
282282
reportedVerb := cleanVerb(verb, req)
283283
dryRun := cleanDryRun(req.URL)
284284
client := cleanUserAgent(utilnet.GetHTTPClient(req))
285-
elapsedMicroseconds := float64(elapsed / time.Microsecond)
286285
elapsedSeconds := elapsed.Seconds()
287286
requestCounter.WithLabelValues(reportedVerb, dryRun, group, version, resource, subresource, scope, component, client, contentType, codeToString(httpCode)).Inc()
288287
deprecatedRequestCounter.WithLabelValues(reportedVerb, group, version, resource, subresource, scope, component, client, contentType, codeToString(httpCode)).Inc()

staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ func RecordDataKeyGeneration(start time.Time, err error) {
150150
dataKeyGenerationLatencies.Observe(sinceInSeconds(start))
151151
}
152152

153-
// sinceInMicroseconds gets the time since the specified start in microseconds.
154-
func sinceInMicroseconds(start time.Time) float64 {
155-
return float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
156-
}
157-
158153
// sinceInSeconds gets the time since the specified start in seconds.
159154
func sinceInSeconds(start time.Time) float64 {
160155
return time.Since(start).Seconds()

staging/src/k8s.io/client-go/util/workqueue/metrics.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,14 @@ func (m *defaultQueueMetrics) updateUnfinishedWork() {
131131
var total float64
132132
var oldest float64
133133
for _, t := range m.processingStartTimes {
134-
age := m.sinceInMicroseconds(t)
134+
age := m.sinceInSeconds(t)
135135
total += age
136136
if age > oldest {
137137
oldest = age
138138
}
139139
}
140-
// Convert to seconds; microseconds is unhelpfully granular for this.
141-
total /= 1000000
142140
m.unfinishedWorkSeconds.Set(total)
143-
m.longestRunningProcessor.Set(oldest / 1000000)
141+
m.longestRunningProcessor.Set(oldest)
144142
}
145143

146144
type noMetrics struct{}
@@ -150,11 +148,6 @@ func (noMetrics) get(item t) {}
150148
func (noMetrics) done(item t) {}
151149
func (noMetrics) updateUnfinishedWork() {}
152150

153-
// Gets the time since the specified start in microseconds.
154-
func (m *defaultQueueMetrics) sinceInMicroseconds(start time.Time) float64 {
155-
return float64(m.clock.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
156-
}
157-
158151
// Gets the time since the specified start in seconds.
159152
func (m *defaultQueueMetrics) sinceInSeconds(start time.Time) float64 {
160153
return m.clock.Since(start).Seconds()

staging/src/k8s.io/client-go/util/workqueue/metrics_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,6 @@ func (m *testMetricsProvider) NewRetriesMetric(name string) CounterMetric {
167167
return &m.retries
168168
}
169169

170-
func TestSinceInMicroseconds(t *testing.T) {
171-
mp := testMetricsProvider{}
172-
c := clock.NewFakeClock(time.Now())
173-
mf := queueMetricsFactory{metricsProvider: &mp}
174-
m := mf.newQueueMetrics("test", c)
175-
dqm := m.(*defaultQueueMetrics)
176-
177-
for _, i := range []int{1, 50, 100, 500, 1000, 10000, 100000, 1000000} {
178-
n := c.Now()
179-
c.Step(time.Duration(i) * time.Microsecond)
180-
if e, a := float64(i), dqm.sinceInMicroseconds(n); e != a {
181-
t.Errorf("Expected %v, got %v", e, a)
182-
}
183-
}
184-
}
185-
186170
func TestMetrics(t *testing.T) {
187171
mp := testMetricsProvider{}
188172
t0 := time.Unix(0, 0)

0 commit comments

Comments
 (0)