@cryptotaxi247 / kubo / commits / 3ffebd942

Record datastore metrics for non-default datastores

License: MIT Signed-off-by: Tommi Virtanen <tv@eagain.net>

Tommi Virtanen committed May 20, 2015 at 15:02 UTC 3ffebd942f1507ee9f1330bc5ef59ee0cf6eeb12
1 file changed +15
repo/fsrepo/fsrepo.go
+15
@@ -11,6 +11,7 @@ import (
11 "strings"
12 "sync"
13
14 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/measure"
15 repo "github.com/ipfs/go-ipfs/repo"
16 "github.com/ipfs/go-ipfs/repo/common"
17 config "github.com/ipfs/go-ipfs/repo/config"
@@ -348,6 +349,20 @@ func (r *FSRepo) openDatastore() error {
349 return fmt.Errorf("unknown datastore type: %s", r.config.Datastore.Type)
350 }
351
352 + // Wrap it with metrics gathering
353 + //
354 + // Add our PeerID to metrics paths to keep them unique
355 + //
356 + // As some tests just pass a zero-value Config to fsrepo.Init,
357 + // cope with missing PeerID.
358 + id := r.config.Identity.PeerID
359 + if id == "" {
360 + // the tests pass in a zero Config; cope with it
361 + id = fmt.Sprintf("uninitialized_%p", r)
362 + }
363 + prefix := "fsrepo." + id + ".datastore"
364 + r.ds = measure.New(prefix, r.ds)
365 +
366 return nil
367 }
368