1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 15:37:19 +00:00
kyverno/pkg/engine/api/stats.go

49 lines
1.1 KiB
Go
Raw Normal View History

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
}
func (ps *PolicyStats) RulesAppliedCount() int {
return ps.rulesAppliedCount
}
func (ps *PolicyStats) RulesErrorCount() int {
return ps.rulesErrorCount
}