mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
Record dataTimestamp as float
This commit is contained in:
parent
bf70d289fb
commit
eb6bb5f84d
@ -116,8 +116,8 @@ func RecordTokenGenAttempt(err error) {
|
||||
tokenGenReqTotal.WithLabelValues(getErrorCode(err)).Inc()
|
||||
}
|
||||
|
||||
func RecordKeyDataTimeStamp(timestamp int64) {
|
||||
dataTimeStamp.WithLabelValues().Set(float64(timestamp))
|
||||
func RecordKeyDataTimeStamp(timestamp float64) {
|
||||
dataTimeStamp.WithLabelValues().Set(timestamp)
|
||||
}
|
||||
|
||||
type gRPCError interface {
|
||||
|
@ -195,13 +195,13 @@ func TestTokenGenMetrics(t *testing.T) {
|
||||
|
||||
func TestRecordKeyDataTimeStamp(t *testing.T) {
|
||||
|
||||
dataTimeStamp1 := time.Now().Unix()
|
||||
dataTimeStamp2 := time.Now().Add(time.Second * 1200).Unix()
|
||||
dataTimeStamp1 := float64(time.Now().Unix())
|
||||
dataTimeStamp2 := float64(time.Now().Add(time.Second * 1200).Unix())
|
||||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
metrics []string
|
||||
want int64
|
||||
want float64
|
||||
emit func()
|
||||
}{
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ func (p *keyCache) syncKeys(ctx context.Context) error {
|
||||
}
|
||||
|
||||
p.verificationKeys.Store(newPublicKeys)
|
||||
externaljwtmetrics.RecordKeyDataTimeStamp(newPublicKeys.DataTimestamp.Unix())
|
||||
externaljwtmetrics.RecordKeyDataTimeStamp(float64(newPublicKeys.DataTimestamp.UnixNano()) / float64(1000000000))
|
||||
|
||||
if keysChanged(oldPublicKeys, newPublicKeys) {
|
||||
p.broadcastUpdate()
|
||||
|
@ -160,9 +160,10 @@ func (m *MockSigner) FetchKeys(ctx context.Context, req *v1alpha1.FetchKeysReque
|
||||
m.supportedKeysFetched.Broadcast()
|
||||
m.supportedKeysLock.RUnlock()
|
||||
|
||||
now := time.Now()
|
||||
return &v1alpha1.FetchKeysResponse{
|
||||
RefreshHintSeconds: 5,
|
||||
DataTimestamp: ×tamppb.Timestamp{Seconds: time.Now().Unix()},
|
||||
DataTimestamp: ×tamppb.Timestamp{Seconds: now.Unix(), Nanos: int32(now.Nanosecond())},
|
||||
Keys: keys,
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user