metrics

package
v1.78.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package metrics provides logging and reporting for policy settings and scopes.

Index

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 Reset

func Reset(origin *setting.Origin)

Reset metrics for the specified policy origin.

func SetHooksForTest

func SetHooksForTest(tb internal.TB, addMetric, setMetric metricFn)

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.

type TestState

type TestState struct {
	Name  string // `$os` in the name will be replaced by the actual operating system name.
	Value int64
}

TestState represents a metric name and its expected value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL