meter

package
v3.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package meter is for instrumentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultMeter is the default meter
	DefaultMeter Meter = NewMeter()
	// DefaultAddress data will be made available on this host:port
	DefaultAddress = ":9090"
	// DefaultPath the meter endpoint where the Meter data will be made available
	DefaultPath = "/metrics"
	// timingObjectives is the default spread of stats we maintain for timings / histograms:
	//defaultTimingObjectives = map[float64]float64{0.0: 0, 0.5: 0.05, 0.75: 0.04, 0.90: 0.03, 0.95: 0.02, 0.98: 0.001, 1: 0}
	// default metric prefix
	DefaultMetricPrefix = "micro_"
	// default label prefix
	DefaultLabelPrefix = "micro_"
)

Functions

func NewContext added in v3.1.5

func NewContext(ctx context.Context, c Meter) context.Context

NewContext put meter in context

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 LabelIter added in v3.1.9

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

func (*LabelIter) Next added in v3.1.9

func (iter *LabelIter) Next(k, v *string) bool

type Labels added in v3.1.9

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

func (Labels) Append added in v3.1.9

func (ls Labels) Append(nls Labels) Labels

func (Labels) Iter added in v3.1.9

func (ls Labels) Iter() *LabelIter

func (Labels) Len added in v3.1.9

func (ls Labels) Len() int

func (Labels) Less added in v3.1.9

func (ls Labels) Less(i, j int) bool

func (Labels) Sort added in v3.1.9

func (ls Labels) Sort()

func (Labels) Swap added in v3.1.9

func (ls Labels) Swap(i, j int)

type Meter added in v3.1.4

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

Meter is an interface for collecting and instrumenting metrics

func FromContext added in v3.1.5

func FromContext(ctx context.Context) (Meter, bool)

FromContext get meter from context

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

Context sets the metrics context

func Label added in v3.1.9

func Label(key, val string) Option

Label sets the label

func Logger

func Logger(l logger.Logger) Option

Logger sets the logger

func Name added in v3.2.1

func Name(n string) Option

Name sets the name

func Path

func Path(value string) Option

Path used to serve metrics over HTTP

func SetOption added in v3.1.5

func SetOption(k, v interface{}) Option

SetOption returns a function to setup a context with given value

type Options

type Options struct {
	Name    string
	Address string
	Path    string
	Labels  Labels
	//TimingObjectives map[float64]float64
	Logger       logger.Logger
	Context      context.Context
	MetricPrefix string
	LabelPrefix  string
}

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