metrics

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package metrics is a small Prometheus registry: counters, gauges and histograms with labels, written in the Prometheus text format (version 0.0.4). It has no dependencies, so every package may record into it.

Labels never carry repository, organization or person names: only bounded values like an RPC procedure, a route pattern, a status or a result. The metrics vx records live in vx.go.

Index

Constants

This section is empty.

Variables

View Source
var (
	RPCRequests = Default.NewCounter("vx_rpc_requests_total",
		"API calls by procedure and HTTP status (connect maps error codes to statuses: 429 is ResourceExhausted).", "procedure", "status")
	RPCDuration = Default.NewHistogram("vx_rpc_duration_seconds",
		"API call latency by procedure.", nil, "procedure")
	HTTPRequests = Default.NewCounter("vx_http_requests_total",
		"HTTP requests outside the API by route pattern, method and status.", "route", "method", "status")
	HTTPDuration = Default.NewHistogram("vx_http_request_duration_seconds",
		"HTTP request latency outside the API by route pattern.", nil, "route")

	Lands = Default.NewCounter("vx_lands_total",
		"Lands by result: landed, conflicts, review (waiting for a person), effort_moved, refused (scope, quota, rules) or error.", "result")
	LandConflictFiles = Default.NewCounter("vx_land_conflict_files_total",
		"Files that conflicted in lands.")
	Rebases = Default.NewCounter("vx_rebases_total",
		"Effort rebase events: started, done, conflicts (stopped on a conflict), aborted.", "event")
	Operations = Default.NewCounter("vx_operations_total",
		"Operation log entries written, by operation (effort.create, ship, org.member, ...).", "op")
	Forecasts = Default.NewCounter("vx_forecasts_total",
		"Background overlap forecast runs by result: ok or error.", "result")
	ForecastDuration = Default.NewHistogram("vx_forecast_duration_seconds",
		"Duration of one background overlap forecast run (one repository's queue).", nil)
	WebhookDeliveries = Default.NewCounter("vx_webhook_deliveries_total",
		"Webhook deliveries by host and HTTP status.", "host", "status")

	BlobOps = Default.NewCounter("vx_blob_ops_total",
		"Object store operations by operation (put, get, has) and result (ok, not_found, error).", "op", "result")
	BlobDuration = Default.NewHistogram("vx_blob_op_duration_seconds",
		"Object store operation latency.", []float64{0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 5}, "op")
	BlobBytes = Default.NewCounter("vx_blob_bytes_total",
		"Bytes read from and written to the object store (uncompressed object data).", "op")

	RateLimited = Default.NewCounter("vx_rate_limited_total",
		"Requests refused by a rate limit, by class: api_token, api_ip, signin, signup, cli_login, webhook.", "class")
	QuotaRefused = Default.NewCounter("vx_quota_refused_total",
		"Requests refused by an organization quota, by quota.", "quota")

	AuditPruned = Default.NewCounter("vx_audit_pruned_total",
		"Operation log entries deleted because they were older than the retention.")
)

The metrics vx records. Label values are bounded: procedures, route patterns, status codes, results and limit classes; never repository, organization or person names.

View Source
var Default = NewRegistry()

Default is the registry vx records into and /metrics serves.

View Source
var DefaultBuckets = []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60}

DefaultBuckets suit request latencies in seconds.

Functions

func RecordOp

func RecordOp(op string)

RecordOp counts one operation log entry; store.LogOp calls it.

Types

type Histogram

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

Histogram counts observations into buckets, per label combination.

func (*Histogram) Count

func (h *Histogram) Count(values ...string) uint64

Count returns how many values were observed (tests).

func (*Histogram) Observe

func (h *Histogram) Observe(v float64, values ...string)

Observe records one value.

type Registry

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

Registry holds metrics and writes them out.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) NewCounter

func (r *Registry) NewCounter(name, help string, labels ...string) *Vec

NewCounter registers a counter in r. Counters only go up.

func (*Registry) NewGauge

func (r *Registry) NewGauge(name, help string, labels ...string) *Vec

NewGauge registers a gauge in r.

func (*Registry) NewHistogram

func (r *Registry) NewHistogram(name, help string, buckets []float64, labels ...string) *Histogram

NewHistogram registers a histogram; nil buckets: DefaultBuckets.

func (*Registry) SetCounterFunc

func (r *Registry) SetCounterFunc(name, help string, read func() []Sample, labels ...string)

SetCounterFunc is SetGaugeFunc for a value that only goes up.

func (*Registry) SetGaugeFunc

func (r *Registry) SetGaugeFunc(name, help string, read func() []Sample, labels ...string)

SetGaugeFunc registers a gauge whose samples read is called for on every scrape (queue depths, pool statistics), or replaces the read function of one registered before: each server started in a process (tests start many) points it at its own database. read must be fast: scrapes wait for it.

func (*Registry) WriteText

func (r *Registry) WriteText(w io.Writer)

WriteText writes every metric in the Prometheus text format, sorted by name.

type Sample

type Sample struct {
	Labels []string // values, in the order of the metric's labels
	Value  float64
}

Sample is one value of a metric read at scrape time.

func One

func One(v float64) []Sample

One is a single unlabeled sample, for SetGaugeFunc.

type Vec

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

Vec is a counter or gauge with labels.

func (*Vec) Add

func (v *Vec) Add(n float64, values ...string)

Add adds n; counters must not go down.

func (*Vec) Inc

func (v *Vec) Inc(values ...string)

Inc adds one.

func (*Vec) Set

func (v *Vec) Set(n float64, values ...string)

Set sets a gauge.

func (*Vec) Value

func (v *Vec) Value(values ...string) float64

Value returns the current value (tests).

Jump to

Keyboard shortcuts

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