aboutsummaryrefslogtreecommitdiff
path: root/middleware/metrics/metrics.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2016-10-28 12:57:10 +0100
committerGravatar GitHub <noreply@github.com> 2016-10-28 12:57:10 +0100
commitcb867ff6bda5a3964a7ffc767cbeeb0b789259be (patch)
tree8dd08149646afa5e0be09ee1058ba4e81320d708 /middleware/metrics/metrics.go
parent0509f4b4aca9f0e516e641921763e3dd5edead4f (diff)
downloadcoredns-cb867ff6bda5a3964a7ffc767cbeeb0b789259be.tar.gz
coredns-cb867ff6bda5a3964a7ffc767cbeeb0b789259be.tar.zst
coredns-cb867ff6bda5a3964a7ffc767cbeeb0b789259be.zip
middleware/metrics: export ListenAddr (#366)
ListenAddr is the address where the prometheus metric are exported. This can be used in tests to listen on "localhost:0" and then later retrieve the metrics from there. It makes the tests indepent on each other.
Diffstat (limited to 'middleware/metrics/metrics.go')
-rw-r--r--middleware/metrics/metrics.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/middleware/metrics/metrics.go b/middleware/metrics/metrics.go
index 5f93ec2f5..ee0e0ed16 100644
--- a/middleware/metrics/metrics.go
+++ b/middleware/metrics/metrics.go
@@ -61,6 +61,7 @@ func (m *Metrics) OnStartup() error {
}
m.ln = ln
+ ListenAddr = m.ln.Addr().String()
m.mux = http.NewServeMux()
@@ -97,3 +98,7 @@ func keys(m map[string]bool) []string {
}
return sx
}
+
+// 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.
+var ListenAddr string