Back to godoc.org

Package metrics

v0.1.10-docs-prerelease
Latest Go to latest

The highest tagged major version is .

Published: Apr 17, 2020 | License: MIT | Module: github.com/spacemeshos/go-spacemesh

Overview

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

Index

Constants

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

Variables

var Enabled = false

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

func StartCollectingMetrics

func StartCollectingMetrics(metricsPort int)

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

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier