Documentation
¶
Overview ¶
rrdmetrics uses RRDTool as a backend to track application metrics, such as for a running web server
Index ¶
- type Logger
- type Metric
- type MetricOption
- type MetricsCollector
- func (c *MetricsCollector) AddGaugeMetric(gf func() float64)
- func (c *MetricsCollector) AddMetric(m Metric)
- func (c *MetricsCollector) ChiMetrics(r chi.Router)
- func (c *MetricsCollector) DBMetric()
- func (c *MetricsCollector) HTTPMetric(metricName string, next http.Handler) http.Handler
- func (c *MetricsCollector) SetLogger(l Logger)
- func (c *MetricsCollector) Track() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
a Metric being tracked by RRDTool
func NewMetric ¶
func NewMetric(name, dsType string, options ...MetricOption) Metric
type MetricOption ¶
type MetricOption func(*Metric)
func WithHeartbeat ¶
func WithHeartbeat(h int) MetricOption
func WithMaxValue ¶
func WithMaxValue(mx int) MetricOption
func WithMinValue ¶
func WithMinValue(mn int) MetricOption
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
func NewCollector ¶
func NewCollector(rrdPath string, step uint) MetricsCollector
NewCollector creates a new metrics collector, which will collect every step seconds. 60 is a good default
func (*MetricsCollector) AddGaugeMetric ¶
func (c *MetricsCollector) AddGaugeMetric(gf func() float64)
Call this function regularly
func (*MetricsCollector) AddMetric ¶
func (c *MetricsCollector) AddMetric(m Metric)
func (*MetricsCollector) ChiMetrics ¶
func (c *MetricsCollector) ChiMetrics(r chi.Router)
ChiMetrics wraps all routes associated with a chi router in
func (*MetricsCollector) DBMetric ¶
func (c *MetricsCollector) DBMetric()
TODO? https://stackoverflow.com/questions/23166411/wrapper-for-arbitrary-function-in-go
func (*MetricsCollector) HTTPMetric ¶
HTTPMetric Generates request middleware that updates each request metricName must be 14 characters or shorter, based on rrd limitations
func (*MetricsCollector) SetLogger ¶
func (c *MetricsCollector) SetLogger(l Logger)
func (*MetricsCollector) Track ¶
func (c *MetricsCollector) Track() error
Track syncs the metrics to the RRD database and begins tracking them. metrics will be stored in a buffer and written every `step` seconds renaming an existing metric will lead to it being truncated -- use rrdtool tune if this concerns you Metrics with the same name with 'double up'. you're responsible for avoiding namespace collisions