Documentation
¶
Overview ¶
Package metrics implements Prometheus-compatible metrics for applications.
This package is similar to https://github.com/prometheus/client_golang , but is simpler to use and is more lightweight.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGauge ¶
NewGauge creates a gauge with the given name, which calls f to obtain gauge value.
name must be valid Prometheus-compatible metric with possible labels. For instance,
- foo
- foo{bar="baz"}
- foo{bar="baz",aaa="b"}
f must be safe for concurrent calls.
func WritePrometheus ¶
WritePrometheus writes all the registered metrics in Prometheus format to w.
If exposeProcessMetrics is true, then various `go_*` metrics are exposed for the current process.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a counter.
It may be used as a gauge if Dec and Set are called.
func NewCounter ¶
NewCounter creates and returns new counter with the given name.
name must be valid Prometheus-compatible metric with possible lables. For instance,
- foo
- foo{bar="baz"}
- foo{bar="baz",aaa="b"}
The returned counter is safe to use from concurrent goroutines.
type Summary ¶
type Summary struct {
// contains filtered or unexported fields
}
Summary implements summary.
func NewSummary ¶
NewSummary creates and returns new summary with the given name.
name must be valid Prometheus-compatible metric with possible lables. For instance,
- foo
- foo{bar="baz"}
- foo{bar="baz",aaa="b"}
The returned summary is safe to use from concurrent goroutines.
func NewSummaryExt ¶
NewSummaryExt creates and returns new summary with the given name, window and quantiles.
name must be valid Prometheus-compatible metric with possible lables. For instance,
- foo
- foo{bar="baz"}
- foo{bar="baz",aaa="b"}
The returned summary is safe to use from concurrent goroutines.
func (*Summary) UpdateDuration ¶
UpdateDuration updates request duration based on the given startTime.