1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-10 18:06:55 +00:00
kyverno/pkg/engine/api/stats.go
Charles-Edouard Brétéché 166122b0ea
refactor: engine response stats (#6796)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-04-06 01:07:04 +08:00

40 lines
1,014 B
Go

package api
import (
"time"
)
// ExecutionStats stores the statistics for the single policy/rule application
type ExecutionStats struct {
// processingTime is the time required to apply the policy/rule on the resource
processingTime time.Duration
// timestamp of the instant the policy/rule got triggered
timestamp time.Time
}
func NewExecutionStats(startTime, endTime time.Time) ExecutionStats {
return ExecutionStats{
timestamp: startTime,
processingTime: endTime.Sub(startTime),
}
}
func (s ExecutionStats) Time() time.Time {
return s.timestamp
}
func (s ExecutionStats) Timestamp() int64 {
return s.timestamp.Unix()
}
func (s ExecutionStats) ProcessingTime() time.Duration {
return s.processingTime
}
// PolicyStats stores statistics for the single policy application
type PolicyStats struct {
// RulesAppliedCount is the count of rules that were applied successfully
RulesAppliedCount int
// RulesErrorCount is the count of rules that with execution errors
RulesErrorCount int
}