提交 3ffebd94 作者: Tommi Virtanen 提交者: Jeromy

Record datastore metrics for non-default datastores

License: MIT
Signed-off-by: 's avatarTommi Virtanen <tv@eagain.net>
上级 8f2d8204
......@@ -11,6 +11,7 @@ import (
"strings"
"sync"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/measure"
repo "github.com/ipfs/go-ipfs/repo"
"github.com/ipfs/go-ipfs/repo/common"
config "github.com/ipfs/go-ipfs/repo/config"
......@@ -348,6 +349,20 @@ func (r *FSRepo) openDatastore() error {
return fmt.Errorf("unknown datastore type: %s", r.config.Datastore.Type)
}
// Wrap it with metrics gathering
//
// Add our PeerID to metrics paths to keep them unique
//
// As some tests just pass a zero-value Config to fsrepo.Init,
// cope with missing PeerID.
id := r.config.Identity.PeerID
if id == "" {
// the tests pass in a zero Config; cope with it
id = fmt.Sprintf("uninitialized_%p", r)
}
prefix := "fsrepo." + id + ".datastore"
r.ds = measure.New(prefix, r.ds)
return nil
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论