Documentation ¶
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.
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 ¶
Counter is a metric type used to represent a monotonically increased/decreased numeric value.
func NewCounter ¶
NewCounter creates a Counter metrics under the global namespace returns nop if metrics are disabled.
type Histogram ¶
Histogram is a metric type used to sum up multiple observations over time.
func NewHistogram ¶
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.