mirror of
https://github.com/folbricht/routedns.git
synced 2025-12-17 15:45:21 -06:00
* Add metric tracking * Clean up metrics structures. * Add available route metric to router.
25 lines
594 B
Go
25 lines
594 B
Go
package rdns
|
|
|
|
import (
|
|
"expvar"
|
|
"fmt"
|
|
)
|
|
|
|
// Get an *expvar.Int with the given path.
|
|
func getVarInt(base string, id string, name string) *expvar.Int {
|
|
fullname := fmt.Sprintf("routedns.%s.%s.%s", base, id, name)
|
|
if v := expvar.Get(fullname); v != nil {
|
|
return v.(*expvar.Int)
|
|
}
|
|
return expvar.NewInt(fullname)
|
|
}
|
|
|
|
// Get an *expvar.Map with the given path.
|
|
func getVarMap(base string, id string, name string) *expvar.Map {
|
|
fullname := fmt.Sprintf("routedns.%s.%s.%s", base, id, name)
|
|
if v := expvar.Get(fullname); v != nil {
|
|
return v.(*expvar.Map)
|
|
}
|
|
return expvar.NewMap(fullname)
|
|
}
|