Documentation ¶
Overview ¶
Package meter is for instrumentation
Index ¶
- Variables
- func BuildLabels(labels ...string) []string
- func BuildName(name string, labels ...string) string
- func NewContext(ctx context.Context, c Meter) context.Context
- type Counter
- type FloatCounter
- type Gauge
- type Histogram
- type Meter
- type Option
- func Address(value string) Option
- func Context(ctx context.Context) Option
- func LabelPrefix(pref string) Option
- func Labels(ls ...string) Option
- func Logger(l logger.Logger) Option
- func MetricPrefix(pref string) Option
- func Name(n string) Option
- func Path(value string) Option
- func SetOption(k, v interface{}) Option
- func WriteFDMetrics(b bool) Option
- func WriteProcessMetrics(b bool) Option
- type Options
- type Summary
Constants ¶
This section is empty.
Variables ¶
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 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 LabelPrefix ¶ added in v3.8.1
LabelPrefix sets the labels prefix
func MetricPrefix ¶ added in v3.8.1
MetricPrefix sets the metric prefix
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 { // Logger used for logging Logger logger.Logger // 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 // MetricPrefix holds the prefix for all metrics MetricPrefix string // LabelPrefix holds the prefix for all labels LabelPrefix 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