Move expvar under the registry section
For consistency with other systems, the redis and caching monitoring data has been moved under the "registry" section in expvar. This ensures the entire registry state is kept to a single section. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
4e1ecad6cc
commit
6b748a74ef
@ -272,13 +272,18 @@ func (app *App) configureRedis(configuration *configuration.Configuration) {
|
||||
|
||||
app.redis = pool
|
||||
|
||||
expvar.Publish("redis", expvar.Func(func() interface{} {
|
||||
// setup expvar
|
||||
registry := expvar.Get("registry")
|
||||
if registry == nil {
|
||||
registry = expvar.NewMap("registry")
|
||||
}
|
||||
|
||||
registry.(*expvar.Map).Set("redis", expvar.Func(func() interface{} {
|
||||
return map[string]interface{}{
|
||||
"Config": configuration.Redis,
|
||||
"Active": app.redis.ActiveCount(),
|
||||
}
|
||||
}))
|
||||
|
||||
}
|
||||
|
||||
func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -174,7 +174,26 @@ var layerInfoCacheMetrics struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
expvar.Publish("layerinfocache", expvar.Func(func() interface{} {
|
||||
registry := expvar.Get("registry")
|
||||
if registry == nil {
|
||||
registry = expvar.NewMap("registry")
|
||||
}
|
||||
|
||||
cache := registry.(*expvar.Map).Get("cache")
|
||||
if cache == nil {
|
||||
cache = &expvar.Map{}
|
||||
cache.(*expvar.Map).Init()
|
||||
registry.(*expvar.Map).Set("cache", cache)
|
||||
}
|
||||
|
||||
storage := cache.(*expvar.Map).Get("storage")
|
||||
if storage == nil {
|
||||
storage = &expvar.Map{}
|
||||
storage.(*expvar.Map).Init()
|
||||
cache.(*expvar.Map).Set("storage", storage)
|
||||
}
|
||||
|
||||
storage.(*expvar.Map).Set("layerinfo", expvar.Func(func() interface{} {
|
||||
// no need for synchronous access: the increments are atomic and
|
||||
// during reading, we don't care if the data is up to date. The
|
||||
// numbers will always *eventually* be reported correctly.
|
||||
|
Loading…
Reference in New Issue
Block a user