Documentation
¶
Overview ¶
rrdmetrics uses RRDTool as a backend to track application metrics, such as for a running web server
Index ¶
- type ChiCollector
- type CollectorOption
- type Metric
- type MetricOption
- type MetricsCollector
- func (c *MetricsCollector) AddGaugeMetric(name string, gf func() float64)
- func (c *MetricsCollector) AddMetric(m Metric)
- func (c *MetricsCollector) HTTPMetric(metricName string) func(http.Handler) http.Handler
- func (c *MetricsCollector) NewChiCollector(m *chi.Mux) ChiCollector
- func (c *MetricsCollector) Run() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChiCollector ¶
type ChiCollector struct { *MetricsCollector // contains filtered or unexported fields }
ChiCollector extends MetricsCollector with some chi-specific stuff
func (*ChiCollector) RouteMetrics ¶
func (c *ChiCollector) RouteMetrics() func(http.Handler) http.Handler
RouteMetrics build a middleware that automatically pulls metrics from routes
func (*ChiCollector) Run ¶
func (c *ChiCollector) Run() error
type CollectorOption ¶
type CollectorOption func(*MetricsCollector)
func WithStepSize ¶
func WithStepSize(s uint) CollectorOption
WithStepSize configures the step size, ie, how frequently in seconds the metric collector writes to RRD
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
Metric is a Metric being tracked by RRDTool metrics share the same namespace, so it's up to you to make sure that they don't collide
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
}
MetricsCollector
func NewCollector ¶
func NewCollector(rrdPath string, options ...CollectorOption) MetricsCollector
NewCollector creates a new metrics collector
func (*MetricsCollector) AddGaugeMetric ¶
func (c *MetricsCollector) AddGaugeMetric(name string, gf func() float64)
AddGaugeMetric will start tracking a metric of a given name whose value is fetched by the function.
func (*MetricsCollector) AddMetric ¶
func (c *MetricsCollector) AddMetric(m Metric)
AddMetric adds a metric to the metrics being tracked
func (*MetricsCollector) HTTPMetric ¶
HTTPMetric returns a middleware that will start collecting metrics for a handler the metric name will be metricName, which must be 14 characters max and only consist of alphanumeric, _ or -
func (*MetricsCollector) NewChiCollector ¶
func (c *MetricsCollector) NewChiCollector(m *chi.Mux) ChiCollector
NewChiCollector extends the metrics collector with some Chi-specific stuff
func (*MetricsCollector) Run ¶
func (c *MetricsCollector) Run() error
Run will syncs the metrics to the RRD database and begin tracking them. 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