prometheus

package module
v3.0.0-...-fe5e310 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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