package metrics

import "k8s.io/apiserver/pkg/admission/plugin/policy/mutating/metrics"

Index

Variables

var (
	// Metrics provides access to mutation admission metrics.
	Metrics = newMutationAdmissionMetrics()
)

Types

type MutatingAdmissionPolicyMetrics

type MutatingAdmissionPolicyMetrics struct {
	// contains filtered or unexported fields
}

MutatingAdmissionPolicyMetrics aggregates Prometheus metrics related to mutation admission control.

func (*MutatingAdmissionPolicyMetrics) ObserveAdmission

func (m *MutatingAdmissionPolicyMetrics) ObserveAdmission(ctx context.Context, elapsed time.Duration, policy, binding string, errorType MutationErrorType)

ObserveAdmission observes a policy mutation, with an optional error to indicate the error that may occur but ignored.

func (*MutatingAdmissionPolicyMetrics) ObserveRejection

func (m *MutatingAdmissionPolicyMetrics) ObserveRejection(ctx context.Context, elapsed time.Duration, policy, binding string, errorType MutationErrorType)

ObserveRejection observes a policy mutation error that was at least one of the reasons for a deny.

func (*MutatingAdmissionPolicyMetrics) Reset

func (m *MutatingAdmissionPolicyMetrics) Reset()

Reset resets all mutation admission-related Prometheus metrics.

type MutationErrorType

type MutationErrorType string

MutationErrorType defines different error types that happen to a mutation expression

const (
	// MutationCompileError indicates that the expression fails to compile.
	MutationCompileError MutationErrorType = "compile_error"
	// MutatingInvalidError indicates that the expression fails due to internal
	// errors that are out of the control of the user.
	MutatingInvalidError MutationErrorType = "invalid_error"
	// MutatingOutOfBudget indicates that the expression fails due to running
	// out of cost budget, or the budget cannot be obtained.
	MutatingOutOfBudget MutationErrorType = "out_of_budget"
	// MutationNoError indicates that the expression returns without an error.
	MutationNoError MutationErrorType = "no_error"
)

func ErrorType

func ErrorType(err error) MutationErrorType

ErrorType decodes the error to determine the error type that the metrics understand.

Source Files

errors.go metrics.go

Version
v0.35.0-alpha.0
Published
Aug 6, 2025
Platform
js/wasm
Imports
6 packages
Last checked
7 hours ago

Tools for package owners.