metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package metrics implements the metrics server.

Index

Constants

View Source
const (
	KindGauge     = "gauge"
	KindHistogram = "histogram"
	KindCounter   = "counter"
)

Constants holding metric kinds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Histogram

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

Histogram is custom type emulating prometheus.Histogram

func NewHistogram

func NewHistogram(opts HistogramOpts) *Histogram

NewHistogram creates new Histogram based on Histogram options

func (*Histogram) Collect

func (h *Histogram) Collect(ch chan<- prometheus.Metric)

Collect sends histogram to a prometheus Metric channel.

func (*Histogram) Desc

func (h *Histogram) Desc() *prometheus.Desc

Desc returns prometheus.Desc used by every Prometheus Metric.

func (*Histogram) Describe

func (h *Histogram) Describe(ch chan<- *prometheus.Desc)

Describe sends metric description to a channel.

func (*Histogram) Set

func (h *Histogram) Set(le float64, val uint64)

Set sets value for a given le.

func (*Histogram) Write

func (h *Histogram) Write(out *dto.Metric) error

Write writes out Histogram data to the Metric dto.

type HistogramOpts

type HistogramOpts struct {
	// Namespace, Subsystem, and Name are components of the fully-qualified
	// name of the Histogram (created by joining these components with
	// "_"). Only Name is mandatory, the others merely help structuring the
	// name. Note that the fully-qualified name of the Histogram must be a
	// valid Prometheus metric name.
	Namespace string
	Subsystem string
	Name      string

	// Help provides information about this Histogram.
	//
	// Metrics with the same fully-qualified name must have the same Help
	// string.
	Help string

	// ConstLabels are used to attach fixed labels to this metric. Metrics
	// with the same fully-qualified name must have the same label names in
	// their ConstLabels.
	//
	// ConstLabels are only used rarely. In particular, do not use them to
	// attach the same labels to all your metrics. Those use cases are
	// better covered by target labels set by the scraping Prometheus
	// server, or by one specific metric (e.g. a build_info or a
	// machine_role metric). See also
	// https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels
	ConstLabels prometheus.Labels
	Buckets     []float64
}

HistogramOpts provides configuration options for Histogram.

type UpdateHandler

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

UpdateHandler handles updating metrics on request

func NewMetricsUpdateHandler

func NewMetricsUpdateHandler(conf UpdateHandlerConfig) (*UpdateHandler, error)

NewMetricsUpdateHandler creates new metric update handler based on the config

func (*UpdateHandler) ServeHTTP

func (h *UpdateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UpdateHandlerConfig

type UpdateHandlerConfig struct {
	NodeName    string
	Metrics     *internalversion.Metric
	Controller  *controllers.Controller
	Environment *cel.Environment
}

UpdateHandlerConfig is configuration for a single node

Directories

Path Synopsis
Package cel implements a metrics evaluator using the Common Expression Language (CEL).
Package cel implements a metrics evaluator using the Common Expression Language (CEL).

Jump to

Keyboard shortcuts

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