mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
b82c1bc386
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
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
|
|
}
|
|
|
|
func (ps *PolicyStats) RulesAppliedCount() int {
|
|
return ps.rulesAppliedCount
|
|
}
|
|
|
|
func (ps *PolicyStats) RulesErrorCount() int {
|
|
return ps.rulesErrorCount
|
|
}
|