Documentation ¶
Overview ¶
Package metrics provides logging and reporting for policy settings and scopes.
Index ¶
- func ReportConfigured(origin *setting.Origin, setting *setting.Definition, value any)
- func ReportError(origin *setting.Origin, setting *setting.Definition, err error)
- func ReportNotConfigured(origin *setting.Origin, setting *setting.Definition)
- func Reset(origin *setting.Origin)
- func SetHooksForTest(tb internal.TB, addMetric, setMetric metricFn)
- func ShouldReport() bool
- type TestHandler
- type TestState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReportConfigured ¶
func ReportConfigured(origin *setting.Origin, setting *setting.Definition, value any)
ReportConfigured updates metrics and logs that the specified setting is configured with the given value in the origin.
func ReportError ¶
func ReportError(origin *setting.Origin, setting *setting.Definition, err error)
ReportError updates metrics and logs that the specified setting has an error in the origin.
func ReportNotConfigured ¶
func ReportNotConfigured(origin *setting.Origin, setting *setting.Definition)
ReportNotConfigured updates metrics and logs that the specified setting is not configured in the origin.
func SetHooksForTest ¶
SetHooksForTest sets the specified addMetric and setMetric functions as the metric functions for the duration of tb and all its subtests.
func ShouldReport ¶
func ShouldReport() bool
ShouldReport reports whether metrics should be reported on the current environment.
Types ¶
type TestHandler ¶
type TestHandler struct {
// contains filtered or unexported fields
}
TestHandler facilitates testing of the code that uses metrics.
func NewTestHandler ¶
func NewTestHandler(t internal.TB) *TestHandler
NewTestHandler returns a new TestHandler.
func (*TestHandler) AddMetric ¶
func (h *TestHandler) AddMetric(name string, typ clientmetric.Type, d int64)
AddMetric increments the metric with the specified name and type by delta d.
func (*TestHandler) MustContain ¶
func (h *TestHandler) MustContain(metrics ...TestState)
MustContain fails the test if the specified metrics are not set or have different values than specified. It permits other metrics to be set in addition to the ones being tested.
func (*TestHandler) MustEqual ¶
func (h *TestHandler) MustEqual(metrics ...TestState)
MustEqual fails the test if the actual metric state differs from the specified state.
func (*TestHandler) SetMetric ¶
func (h *TestHandler) SetMetric(name string, typ clientmetric.Type, v int64)
SetMetric sets the metric with the specified name and type to the value v.