Port: Telemetry For Lease Expiration Times (#10375)

* port lease metrics

* go mod vendor

* caught a bug
This commit is contained in:
Hridoy Roy
2020-11-13 10:26:58 -08:00
committed by GitHub
parent d9fb082c24
commit 0767980550
11 changed files with 624 additions and 59 deletions

View File

@@ -37,3 +37,22 @@ func TTLBucket(ttl time.Duration) string {
}
}
func ExpiryBucket(expiryTime time.Time, leaseEpsilon time.Duration, rollingWindow time.Time, labelNS string, useNS bool) *LeaseExpiryLabel {
if !useNS {
labelNS = ""
}
leaseExpiryLabel := LeaseExpiryLabel{LabelNS: labelNS}
// calculate rolling window
if expiryTime.Before(rollingWindow) {
leaseExpiryLabel.LabelName = expiryTime.Round(leaseEpsilon).String()
return &leaseExpiryLabel
}
return nil
}
type LeaseExpiryLabel = struct {
LabelName string
LabelNS string
}