metric

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRegister

func MustRegister(reg prometheus.Registerer)

MustRegister() registers the CapacityUsage metrics so they can be scraped by Prometheus, exiting on failure.

func Register

func Register(reg prometheus.Registerer) error

Register() registers the CapacityUsage metrics so they can be scraped by Prometheus, returning an error on failure.

Types

type CapacityUsage

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

A CapacityUsage uses two Prometheus gauge metrics, by default, "capacity_min_utilization" and "capacity_max_utilization". They represent the minimum/maximum resource utilization over the recent period of time. Each value will be between 0.0 and 1.0. They each have three labels: "resource", "domain", and "period".

The "capacity" prefix to the metric names can be changed by setting the "PROM_SYSTEM" environment variable.

func NewCapacityUsage

func NewCapacityUsage(
	capacity float64, resource, domain, interval string,
) (*CapacityUsage, error)

NewCapacityUsage() returns a CapacityUsage with a new set of labels to record the utilization of a limited resource where this utilization might spike for a short period and so a single Prometheus Gauge is not sufficient to capture such spikes.

'capacity' is the quantity of the limited resource (e.g. the number of slots). 'resource' is the name of the resource (e.g. "span-creation-backlog"), 'domain' is the domain in which the resource resides (e.g. a workload name), and 'interval' is a string representing a time.Duration over which min and max utilization are measured.

metric.Register() or metric.MustRegister() must be called for these metrics to be exposed to be scraped by Prometheus.

func (*CapacityUsage) Record

func (m *CapacityUsage) Record(used float64)

Record() records the current usage level of the limited resource. 'used' should be a value between 0 and the 'capacity' value passed to NewCapacityUsage(). Division is done to change this number to be a utilization level, a number between 0.0 and 1.0.

Jump to

Keyboard shortcuts

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