Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //ErrMetricAlreadyExist is when trying to add a new metric but it collides with another named metric ErrMetricAlreadyExist = errors.New("trying to add a metric that already exists, instead try to increment it") // ErrMetricNotFound is when trying to increment a nonfound metric ErrMetricNotFound = errors.New("trying to increment a missing metric") )
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric struct { Description string `json:"description" yaml:"description"` Name string `json:"name" yaml:"name"` Value float64 `json:"value" yaml:"value"` }
Metric is information about a certain value of a processor with a name and description, currently all metric is int64, would be cool with interface, but I cant think of a reason
type PrometheusProvider ¶
type PrometheusProvider struct { Metrics map[string]*Metric `json:"metrics"` // PromMetric is actually just a mirror of Metrics, its used to export the metric // The reaason why we contain our own Metric aswell is because it seems hard to extract values from Prom package PromMetrics map[string]prometheus.Counter `json:"-"` sync.Mutex }
PrometheusProvider is a simple Provider for Prom metric for now only support Float64, maybe add more in the future
func NewPrometheusProvider ¶
func NewPrometheusProvider() *PrometheusProvider
NewPrometheusProvider will generate a new metrics holder
func (*PrometheusProvider) AddMetric ¶
func (pp *PrometheusProvider) AddMetric(m *Metric) error
AddMetric is used to add new metrics, or append to old metric
func (*PrometheusProvider) GetMetric ¶
func (pp *PrometheusProvider) GetMetric(name string) *Metric
GetMetric will return a metric if it exists, or nil if not
func (*PrometheusProvider) GetMetrics ¶
func (pp *PrometheusProvider) GetMetrics() map[string]*Metric
GetMetrics is used to extract all metrics
func (*PrometheusProvider) IncrementMetric ¶
func (pp *PrometheusProvider) IncrementMetric(name string, value float64) error
IncrementMetric is used to increase value of metric
Click to show internal directories.
Click to hide internal directories.