probe

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled returns true if probe is started

func Start

func Start()

Start creates a probe which serves metrics via HTTP server, if it is enabled by config and not already started. Start is not thread-safe, caller should use due guards if necessary

func Stop

func Stop()

Stop stops the HTTP server. Stop is not thread-safe, caller should use due guards if necessary

Types

type Config

type Config struct {
	Enabled       bool            `mapstructure:"enable"`
	ServerConfig  *ServerConfig   `mapstructure:"server"`
	MetricConfigs *[]MetricConfig `mapstructure:"metrics"`
}

func GetConfig

func GetConfig() *Config

type CounterMetric

type CounterMetric interface {
	prometheus.Counter
}

type GaugeMetric

type GaugeMetric interface {
	prometheus.Gauge
}

type HistogramMetric

type HistogramMetric interface {
	prometheus.Histogram
}

type Metric

type Metric interface {
	prometheus.Metric
}

func Get

func Get(metricId string) (Metric, bool)

Get gets the metric for the given metricId. Caller can use the returned metric by casting it to one of appropriate metric types; probe.GaugeMetric, probe.CounterMetric, probe.HistogramMetric - On success, returns (metric, true) - If probe is disabled or not started returns (nil, false)

func Set

func Set(metricConfig MetricConfig) (Metric, bool)

Set creates a metric with given metricConfig if probe is enabled and started. If config file contains a metric with same id as metricConfig.Id, metricConfig values are overwritten by config file. Caller can use the returned metric by casting it to one of appropriate metric types; probe.GaugeMetric, probe.CounterMetric, probe.HistogramMetric

  • On success, returns (metric, true)
  • If probe is disabled or not started, returns (nil, false)
  • If there is a metric created with same id previously, returns the previously created metric.

type MetricConfig

type MetricConfig struct {
	Id          string    `mapstructure:"id"`
	Type        string    `mapstructure:"type"`
	Name        string    `mapstructure:"name"`
	Help        string    `mapstructure:"help"`
	Buckets     []float64 `mapstructure:"buckets"`
	LabelNames  []string  `mapstructure:"labelNames"`
	LabelValues []string  `mapstructure:"labelValues"`
}

type ServerConfig

type ServerConfig struct {
	Address   string `mapstructure:"address"`
	Namespace string `mapstructure:"namespace"`
	Subsystem string `mapstructure:"subsystem"`
}

Jump to

Keyboard shortcuts

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