mirror of
https://github.com/coredns/coredns.git
synced 2025-12-07 02:45:11 -05:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user