metrics

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

Metrics package

The metrics package contains a pattern to add Prometheus type metrics to a MantisNet program. It has useful tools to integrate with cobra and viper command line framework to configure flags, and a wrapper around the Prometheus client package to normalize it's utilization within MantisNet.

Current assigned ports

  • bflow: 9901
  • bftpassembly: 9902
  • bs3archive: 9903
  • btransform: 9904
  • ppe: 9905
  • rfpng_exporter: 9906

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigFlags

func ConfigFlags(cmd *cobra.Command, prefix, defaultNamespace, defaultHTTP, defaultPath string) error

ConfigFlags helps configure cobra and viper flags.

Types

type Config

type Config struct {
	Namespace string `mapstructure:"namespace"`
	Enable    bool   `mapstructure:"enable"`
	Addr      string `mapstructure:"addr"`
	Path      string `mapstructure:"path"`
}

Config configures the metrics client.

func (*Config) Validate

func (c *Config) Validate() error

Validate configuration is ok

type Logger

type Logger func(format string, v ...interface{})

Logger is the expected logger for the manual print out of the metrics

type Metrics

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

Metrics enables app metrics

func New

func New(config *Config) (*Metrics, error)

New initializes the configured Metrics

func (*Metrics) Counter

func (m *Metrics) Counter(name, help string) prometheus.Counter

Counter gets or creates an expvar Float with the given name, and returns an object that implements the Counter interface.

func (*Metrics) CounterVec

func (m *Metrics) CounterVec(name, help string, labels ...string) *prometheus.CounterVec

CounterVec creates a new CounterVec based on the provided CounterOpts and partitioned by the given label names.

func (*Metrics) Gauge

func (m *Metrics) Gauge(name, help string) prometheus.Gauge

Gauge get or creates an expvar Float with the given name, and returns an object that implements the Gauge interface.

func (*Metrics) GaugeVec

func (m *Metrics) GaugeVec(name, help string, labels ...string) *prometheus.GaugeVec

GaugeVec creates a new GaugeVec based on the provided GaugeOpts and partitioned by the given label names.

func (*Metrics) Histogram

func (m *Metrics) Histogram(name, help string, buckets []float64) prometheus.Histogram

Histogram counts individual observations from an event or sample stream in configurable buckets. Similar to a summary, it also provides a sum of observations and an observation count.

On the Prometheus server, quantiles can be calculated from a Histogram using the histogram_quantile function in the query language.

Note that Histograms, in contrast to Summaries, can be aggregated with the Prometheus query language (see the documentation for detailed procedures). However, Histograms require the user to pre-define suitable buckets, and they are in general less accurate. The Observe method of a Histogram has a very low performance overhead in comparison with the Observe method of a Summary.

func (*Metrics) HistogramVec

func (m *Metrics) HistogramVec(name, help string, buckets []float64, labels ...string) *prometheus.HistogramVec

HistogramVec is a Collector that bundles a set of Histograms that all share the same Desc, but have different values for their variable labels. This is used if you want to count the same thing partitioned by various dimensions (e.g. HTTP request latencies, partitioned by status code and method). Create instances with NewHistogramVec.

func (*Metrics) Log

func (m *Metrics) Log(l Logger, all bool)

Log a human readable output of the metrics. This is not optimized, only to be used for debugging.

Jump to

Keyboard shortcuts

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