meter

package
v3.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

README

metrics

The metrics package provides a simple metrics "Reporter" interface which allows the user to submit counters, gauges and timings (along with key/value tags).

Implementations

  • Prometheus (pull): will be first
  • Prometheus (push): certainly achievable
  • InfluxDB: could quite easily be done
  • Telegraf: almost identical to the InfluxDB implementation
  • Micro: Could we provide metrics over Micro's server interface?

Todo

  • Include a handler middleware which uses the Reporter interface to generate per-request level metrics
    • Throughput
    • Errors
    • Duration

Documentation

Overview

Package meter is for instrumentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// The Meter data will be made available on this port
	DefaultAddress = ":9090"
	// This is the endpoint where the Meter data will be made available ("/metrics" is the default)
	DefaultPath = "/metrics"
)

Functions

This section is empty.

Types

type Counter added in v3.1.4

type Counter interface {
	Add(int)
	Dec()
	Get() uint64
	Inc()
	Set(uint64)
}

Counter is a counter

type FloatCounter added in v3.1.4

type FloatCounter interface {
	Add(float64)
	Get() float64
	Set(float64)
	Sub(float64)
}

FloatCounter is a float64 counter

type Gauge added in v3.1.4

type Gauge interface {
	Get() float64
}

Gauge is a float64 gauge

type Histogram added in v3.1.4

type Histogram interface {
	Reset()
	Update(float64)
	UpdateDuration(time.Time)
}

Histogram is a histogram for non-negative values with automatically created buckets

type Meter added in v3.1.4

type Meter interface {
	Init(...Option) error
	Counter(string, metadata.Metadata) Counter
	FloatCounter(string, metadata.Metadata) FloatCounter
	Gauge(string, func() float64, metadata.Metadata) Gauge
	Set(metadata.Metadata) Meter
	Histogram(string, metadata.Metadata) Histogram
	Summary(string, metadata.Metadata) Summary
	SummaryExt(string, time.Duration, []float64, metadata.Metadata) Summary
	Options() Options
	String() string
}

Meter is an interface for collecting and instrumenting metrics

var (
	DefaultReporter Meter = NewMeter()
)

func NewMeter added in v3.1.4

func NewMeter(opts ...Option) Meter

NewMeter returns a configured noop reporter:

type Option

type Option func(*Options)

Option powers the configuration for metrics implementations:

func Address

func Address(value string) Option

Address is the listen address to serve metrics

func Context

func Context(ctx context.Context) Option

Cntext sets the metrics context

func Logger

func Logger(l logger.Logger) Option

Logger sets the logger

func Metadata added in v3.1.4

func Metadata(md metadata.Metadata) Option

Metadata will be added to every metric

func Path

func Path(value string) Option

Path used to serve metrics over HTTP

type Options

type Options struct {
	Address  string
	Path     string
	Metadata metadata.Metadata
	//TimingObjectives map[float64]float64
	Logger  logger.Logger
	Context context.Context
}

Options for metrics implementations:

func NewOptions

func NewOptions(opt ...Option) Options

NewOptions prepares a set of options:

type Summary added in v3.1.4

type Summary interface {
	Update(float64)
	UpdateDuration(time.Time)
}

Summary is the summary

Jump to

Keyboard shortcuts

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