pkg/metrics: self-manage global expvar map

This helps the embedded tests.
This commit is contained in:
Yicheng Qin
2015-01-26 07:47:27 -08:00
parent 93e4880ae6
commit 08b34a3f5b
3 changed files with 110 additions and 24 deletions

View File

@@ -37,6 +37,7 @@ import (
"github.com/coreos/etcd/etcdserver/etcdhttp/httptypes"
"github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/etcdserver/stats"
"github.com/coreos/etcd/pkg/metrics"
"github.com/coreos/etcd/pkg/types"
"github.com/coreos/etcd/raft"
"github.com/coreos/etcd/store"
@@ -292,7 +293,7 @@ func serveStats(w http.ResponseWriter, r *http.Request) {
// TODO: getting one key or a prefix of keys based on path
fmt.Fprintf(w, "{\n")
first := true
expvar.Do(func(kv expvar.KeyValue) {
metrics.Do(func(kv expvar.KeyValue) {
if !first {
fmt.Fprintf(w, ",\n")
}