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:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user