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" // DefaultMeterStatsInterval specifies interval for meter updating DefaultMeterStatsInterval = 5 * time.Second // 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 // DefaultSkipEndpoints is the slice of endpoint that must not be metered DefaultSkipEndpoints = []string{ "MeterService.Metrics", "HealthService.Live", "HealthService.Ready", "HealthService.Version", } )
Functions ¶
func BuildLabels ¶
BuildLabels used to sort labels and delete duplicates. Last value wins in case of duplicate label keys.
Types ¶
type FloatCounter ¶
FloatCounter is a float64 counter
type Histogram ¶
Histogram is a histogram for non-negative values with automatically created buckets
type Meter ¶
type Meter interface { // Name returns meter name Name() string // Init initialize meter Init(opts ...Option) error // Clone create meter copy with new options Clone(opts ...Option) Meter // Counter get or create counter Counter(name string, labels ...string) Counter // FloatCounter get or create float counter FloatCounter(name string, labels ...string) FloatCounter // Gauge get or create gauge Gauge(name string, fn func() float64, labels ...string) Gauge // Set create new meter metrics set Set(opts ...Option) Meter // Histogram get or create histogram Histogram(name string, labels ...string) Histogram // Summary get or create summary Summary(name string, labels ...string) Summary // SummaryExt get or create summary with spcified quantiles and window time SummaryExt(name string, window time.Duration, quantiles []float64, labels ...string) Summary // Write writes metrics to io.Writer Write(w io.Writer, opts ...Option) error // Options returns meter options Options() Options // String return meter type String() string }
Meter is an interface for collecting and instrumenting metrics
func FromContext ¶
FromContext get meter from context
type Option ¶
type Option func(*Options)
Option powers the configuration for metrics implementations:
func SetOption ¶
func SetOption(k, v interface{}) Option
SetOption returns a function to setup a context with given value
func WriteFDMetrics ¶
WriteFDMetrics enable fd metrics output for write
func WriteProcessMetrics ¶
WriteProcessMetrics enable process metrics output for write
type Options ¶
type Options struct { // Context holds external options Context context.Context // Name holds the meter name Name string // Address holds the address that serves metrics Address string // Path holds the path for metrics Path string // Labels holds the default labels Labels []string // WriteProcessMetrics flag to write process metrics WriteProcessMetrics bool // WriteFDMetrics flag to write fd metrics WriteFDMetrics bool }
Options for metrics implementations
Click to show internal directories.
Click to hide internal directories.