metrics

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metrics defines telemetry primitives to be used across components. it uses the prometheus format.

Index

Constants

View Source
const (
	// Namespace is the basic namespace where all metrics are defined under.
	Namespace = "spacemesh"
	// ResultLabel makes a consistent name for results.
	ResultLabel = "result"
)

Variables

View Source
var Enabled = false

Enabled variable is used to turn on or of the metrics server. when set to false nop metrics are used.

Functions

func StartCollectingMetrics

func StartCollectingMetrics(metricsPort int)

StartCollectingMetrics begins listening and supplying metrics on localhost:`metricsPort`/metrics

Types

type Cache

type Cache interface {
	Add(key, value interface{}) (evicted bool)
	Get(key interface{}) (value interface{}, ok bool)
}

Cache is a basic cache interface that we can wrap to meter.

type Counter

type Counter metrics.Counter

Counter is a metric type used to represent a monotonically increased/decreased numeric value.

func NewCounter

func NewCounter(name, subsystem, help string, labels []string) Counter

NewCounter creates a Counter metrics under the global namespace returns nop if metrics are disabled.

type Gauge

type Gauge metrics.Gauge

Gauge is a metric type used to represent a numeric value

func NewGauge

func NewGauge(name, subsystem, help string, labels []string) Gauge

NewGauge creates a Gauge metrics under the global namespace returns nop if metrics are disabled.

type Histogram

type Histogram metrics.Histogram

Histogram is a metric type used to sum up multiple observations over time.

func NewHistogram

func NewHistogram(name, subsystem, help string, labels []string) Histogram

NewHistogram creates a Histogram metrics under the global namespace returns nop if metrics are disabled.

type MeteredCache

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

MeteredCache is a wrapper around a cache that monitors size, hits and misses.

func NewMeteredCache

func NewMeteredCache(cache Cache, subsystem, name, help string, labels []string) *MeteredCache

NewMeteredCache wraps cache with metrics are returns a monitored cache.

func (*MeteredCache) Add

func (m *MeteredCache) Add(key, value interface{}) bool

Add adds a key-value to the cache and increases the counter if needed.

func (*MeteredCache) Get

func (m *MeteredCache) Get(key interface{}) (value interface{}, ok bool)

Get returns a value from the cache and counts a hit or a miss.

Jump to

Keyboard shortcuts

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