prometheus

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

Prometheus

A Prometheus "pull" based implementation of the metrics Reporter interface.

Capabilities

  • Go runtime metrics are handled natively by the Prometheus client library (CPU / MEM / GC / GoRoutines etc).
  • User-defined metrics are registered in the Prometheus client dynamically (they must be pre-registered, hence all of the faffing around in metric_family.go).
  • The metrics are made available on a Prometheus-compatible HTTP endpoint, which can be scraped at any time. This means that the user can very easily access stats even running locally as a standalone binary.
  • Requires a micro.Server parameter (from which it gathers the service name and version). These are included as tags with every metric.

Usage

    prometheusReporter := metrics.New(server)
    tags := metrics.Tags{"greeter": "Janos"}
    err := prometheusReporter.Count("hellos", 1, tags)
    if err != nil {
        fmt.Printf("Error setting a Count metric: %v", err)
    }

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPrometheusPanic = errors.New("The Prometheus client panicked. Did you do something like change the tag cardinality or the type of a metric?")

ErrPrometheusPanic is a catch-all for the panics which can be thrown by the Prometheus client:

Functions

This section is empty.

Types

type Reporter

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

Reporter is an implementation of metrics.Reporter:

func New

func New(opts ...metrics.Option) (*Reporter, error)

New returns a configured prometheus reporter:

func (*Reporter) Count

func (r *Reporter) Count(name string, value int64, tags metrics.Tags) (err error)

Count is a counter with key/value tags: New values are added to any previous one (eg "number of hits")

func (*Reporter) Gauge

func (r *Reporter) Gauge(name string, value float64, tags metrics.Tags) (err error)

Gauge is a register with key/value tags: New values simply override any previous one (eg "current connections")

func (*Reporter) Timing

func (r *Reporter) Timing(name string, value time.Duration, tags metrics.Tags) (err error)

Timing is a histogram with key/valye tags: New values are added into a series of aggregations

Jump to

Keyboard shortcuts

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