Documentation ¶
Overview ¶
Package metrics implement a handler and plugin that provides Prometheus metrics.
Index ¶
- Variables
- func WithServer(ctx context.Context) string
- func WithView(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
- type Recorder
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 WithServer ¶ added in v1.1.2
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 ¶ added in v1.0.2
func (m *Metrics) MustRegister(c prometheus.Collector)
MustRegister wraps m.Reg.MustRegister.
func (*Metrics) OnFinalShutdown ¶ added in v1.1.2
OnFinalShutdown tears down the metrics listener on shutdown and restart.
func (*Metrics) RemoveZone ¶
RemoveZone remove zone z from m.
type Recorder ¶ added in v1.8.7
type Recorder struct { *dnstest.Recorder // CallerN holds the string return value of the call to runtime.Caller(N+1) Caller [3]string }
Recorder is a dnstest.Recorder specific to the metrics plugin.
func NewRecorder ¶ added in v1.8.7
func NewRecorder(w dns.ResponseWriter) *Recorder
NewRecorder makes and returns a new Recorder.