meter

package
v3.2.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 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"
	// DefaultMetricPrefix holds the string that prepends to all metrics
	DefaultMetricPrefix = "micro_"
	// DefaultLabelPrefix holds the string that prepends to all labels
	DefaultLabelPrefix = "micro_"
	// DefaultSummaryQuantiles is the default spread of stats for summary
	DefaultSummaryQuantiles = []float64{0.5, 0.9, 0.97, 0.99, 1}
	// DefaultSummaryWindow is the default window for summary
	DefaultSummaryWindow = 5 * time.Minute
)

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
}

LabelIter holds the

func (*LabelIter) Next added in v3.1.9

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

Next advance itarator to new pos

type Labels added in v3.1.9

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

Labels holds the metrics labels with k, v

func (Labels) Append added in v3.1.9

func (ls Labels) Append(nls Labels) Labels

Append adds labels to label set

func (Labels) Iter added in v3.1.9

func (ls Labels) Iter() *LabelIter

Iter returns labels iterator

type Meter added in v3.1.4

type Meter interface {
	Name() string
	Init(opts ...Option) error
	Counter(name string, opts ...Option) Counter
	FloatCounter(name string, opts ...Option) FloatCounter
	Gauge(name string, fn func() float64, opts ...Option) Gauge
	Set(opts ...Option) Meter
	Histogram(name string, opts ...Option) Histogram
	Summary(name string, opts ...Option) Summary
	SummaryExt(name string, window time.Duration, quantiles []float64, opts ...Option) Summary
	Write(w io.Writer, opts ...Option) 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

func WriteFDMetrics added in v3.2.12

func WriteFDMetrics(b bool) Option

WriteFDMetrics enable fd metrics output for write

func WriteProcessMetrics added in v3.2.12

func WriteProcessMetrics(b bool) Option

WriteProcessMetrics enable process metrics output for write

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
	WriteProcessMetrics bool
	WriteFDMetrics      bool
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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