Documentation ¶
Overview ¶
Package metrics implement a handler and plugin that provides Prometheus metrics.
Index ¶
- Variables
- func MustRegister(c *caddy.Controller, cs ...prometheus.Collector)
- func WithServer(ctx context.Context) string
- type Metrics
- func (m *Metrics) AddZone(z string)
- func (m *Metrics) MustRegister(c prometheus.Collector)
- func (m *Metrics) Name() string
- func (m *Metrics) OnFinalShutdown() error
- func (m *Metrics) OnRestart() error
- func (m *Metrics) OnStartup() error
- func (m *Metrics) RemoveZone(z string)
- func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (m *Metrics) ZoneNames() []string
Constants ¶
This section is empty.
Variables ¶
var ListenAddr string
ListenAddr is assigned the address of the prometheus listener. Its use is mainly in tests where we listen on "localhost:0" and need to retrieve the actual address.
Functions ¶
func MustRegister ¶
func MustRegister(c *caddy.Controller, cs ...prometheus.Collector)
MustRegister registers the prometheus Collectors when the metrics middleware is used.
func WithServer ¶
WithServer returns the current server handling the request. It returns the server listening address: <scheme>://[<bind>]:<port> Normally this is something like "dns://:53", but if the bind plugin is used, i.e. "bind 127.0.0.53", it will be "dns://127.0.0.53:53", etc. If not address is found the empty string is returned.
Basic usage with a metric:
<metric>.WithLabelValues(metrics.WithServer(ctx), labels..).Add(1)
Types ¶
type Metrics ¶
type Metrics struct { Next plugin.Handler Addr string Reg *prometheus.Registry // contains filtered or unexported fields }
Metrics holds the prometheus configuration. The metrics' path is fixed to be /metrics
func (*Metrics) MustRegister ¶
func (m *Metrics) MustRegister(c prometheus.Collector)
MustRegister wraps m.Reg.MustRegister.
func (*Metrics) OnFinalShutdown ¶
OnFinalShutdown tears down the metrics listener on shutdown and restart.
func (*Metrics) RemoveZone ¶
RemoveZone remove zone z from m.