prom

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package prom contains some utility functions for dealing with prometheus metrics.

Index

Constants

View Source
const (
	// LabelResult is the label for result classifications.
	LabelResult = "result"
	// LabelStatus for latency status classifications, possible values are prefixed with Status*.
	LabelStatus = "status"
	// LabelOperation is the label for the name of an executed operation.
	LabelOperation = "op"
	// LabelSrc is the label for the source.
	LabelSrc = "src"
	// LabelDst is the label for the destination.
	LabelDst = "dst"
	// LabelNeighIA is label for the neighboring IA.
	LabelNeighIA = "neighbor_isd_as"
)

Common label values.

View Source
const (
	// Success is no error.
	Success = "ok_success"
	// ErrCrypto is used for crypto related errors.
	ErrCrypto = "err_crypto"
	// ErrDB is used for db related errors.
	ErrDB = "err_db"
	// ErrInternal is an internal error.
	ErrInternal = "err_internal"
	// ErrInvalidReq is an invalid request.
	ErrInvalidReq = "err_invalid_request"
	// ErrNotClassified is an error that is not further classified.
	ErrNotClassified = "err_not_classified"
	// ErrParse failed to parse request.
	ErrParse = "err_parse"
	// ErrProcess is an error during processing e.g. parsing failed.
	ErrProcess = "err_process"
	// ErrTimeout is a timeout error.
	ErrTimeout = "err_timeout"
	// ErrValidate is used for validation related errors.
	ErrValidate = "err_validate"
	// ErrVerify is used for verification related errors.
	ErrVerify = "err_verify"
	// ErrNetwork is used for errors when sending something over the network.
	ErrNetwork = "err_network"
	// ErrNotFound is used for errors where a resource is not found.
	ErrNotFound = "err_not_found"
	// ErrUnavailable is used for errors where a resource is not available.
	ErrUnavailable = "err_unavailable"
)

Common result values.

View Source
const (
	StatusErr     = "err"
	StatusTimeout = "err_timeout"
)

FIXME(roosd): remove when moving messenger to new metrics style.

Variables

View Source
var (
	// DefaultLatencyBuckets 10ms, 20ms, 40ms, ... 5.12s, 10.24s.
	DefaultLatencyBuckets = []float64{0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64,
		1.28, 2.56, 5.12, 10.24}
	// DefaultSizeBuckets 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384
	DefaultSizeBuckets = []float64{32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}
)

Functions

func ExportElementID added in v0.4.0

func ExportElementID(id string)

ExportElementID exports the element ID as configured in the config file.

func NewCounter

func NewCounter(namespace, subsystem, name, help string) prometheus.Counter

NewCounter creates a new prometheus counter that is registered with the default registry.

func NewCounterVec

func NewCounterVec(namespace, subsystem, name, help string,
	labelNames []string) *prometheus.CounterVec

NewCounterVec creates a new prometheus counter vec that is registered with the default registry.

func NewCounterVecWithLabels added in v0.4.0

func NewCounterVecWithLabels(ns, sub, name, help string, label Labels) *prometheus.CounterVec

NewCounterVecWithLabels creates a prometheus counter vec that is registered with the default registry and with a default init values for labels to avoid missing metrics.

func NewGauge

func NewGauge(namespace, subsystem, name, help string) prometheus.Gauge

NewGauge creates a new prometheus gauge that is registered with the default registry.

func NewGaugeVec

func NewGaugeVec(namespace, subsystem, name, help string,
	labelNames []string) *prometheus.GaugeVec

NewGaugeVec creates a new prometheus gauge vec that is registered with the default registry.

func NewGaugeVecWithLabels added in v0.4.0

func NewGaugeVecWithLabels(namespace, subsystem, name, help string,
	label Labels) *prometheus.GaugeVec

NewGaugeVecWithLabels creates a new prometheus gauge vec that is registered with the default registry.

func NewHistogram added in v0.4.0

func NewHistogram(namespace, subsystem, name, help string, buckets []float64) prometheus.Histogram

NewHistogram creates a new prometheus histogram that is registered with the default registry.

func NewHistogramVec

func NewHistogramVec(namespace, subsystem, name, help string,
	labelNames []string, buckets []float64) *prometheus.HistogramVec

NewHistogramVec creates a new prometheus histogram vec that is registered with the default registry.

func NewHistogramVecWithLabels added in v0.4.0

func NewHistogramVecWithLabels(namespace, subsystem, name, help string,
	label Labels, buckets []float64) *prometheus.HistogramVec

NewHistogramVecWithLabels creates a new prometheus histogram vec that is registered with the default registry.

func SafeRegister added in v0.4.0

func SafeRegister(c prometheus.Collector) prometheus.Collector

SafeRegister registers c and returns the registered collector. If c was already registered the already registered collector is returned. In case of any other error this method panicks (as MustRegister).

Types

type Labels added in v0.4.0

type Labels interface {
	Labels() []string
	Values() []string
}

Labels allows to safely pass label values into prometheus.

Directories

Path Synopsis
Package promtest contains helpers to test metrics structs.
Package promtest contains helpers to test metrics structs.

Jump to

Keyboard shortcuts

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