1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-20 19:19:06 +08:00

Record datastore metrics for non-default datastores

License: MIT
Signed-off-by: Tommi Virtanen <tv@eagain.net>
This commit is contained in:
Tommi Virtanen
2015-05-20 15:02:35 -07:00
committed by Jeromy
parent 8f2d820412
commit 3ffebd942f

View File

@ -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
}