From 906f45edd9899352efba710e2f53978fc4b8c6e4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 16 Jan 2020 16:18:53 -0800 Subject: [PATCH] fix(tracing): remove event tracing We've deprecated this system and have yet to move to a new system. We might as well remove everything, switch to a new system, then deliberately trace the entire system. --- core/bootstrap/bootstrap.go | 8 -------- core/corehttp/logs.go | 2 +- core/corerepo/gc.go | 1 - fuse/readonly/readonly_unix.go | 16 ++-------------- gc/gc.go | 16 ---------------- go.sum | 1 + namesys/resolve/resolve.go | 12 ------------ 7 files changed, 4 insertions(+), 52 deletions(-) diff --git a/core/bootstrap/bootstrap.go b/core/bootstrap/bootstrap.go index e6ec29eea..4edc5ac84 100644 --- a/core/bootstrap/bootstrap.go +++ b/core/bootstrap/bootstrap.go @@ -18,7 +18,6 @@ import ( "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peerstore" "github.com/libp2p/go-libp2p-core/routing" - "github.com/libp2p/go-libp2p-loggables" ) var log = logging.Logger("bootstrap") @@ -86,10 +85,8 @@ func Bootstrap(id peer.ID, host host.Host, rt routing.Routing, cfg BootstrapConf // the periodic bootstrap function -- the connection supervisor periodic := func(worker goprocess.Process) { ctx := goprocessctx.OnClosingContext(worker) - defer log.EventBegin(ctx, "periodicBootstrap", id).Done() if err := bootstrapRound(ctx, host, cfg); err != nil { - log.Event(ctx, "bootstrapError", id, loggables.Error(err)) log.Debugf("%s bootstrap error: %s", id, err) } @@ -126,7 +123,6 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er // determine how many bootstrap connections to open connected := host.Network().Peers() if len(connected) >= cfg.MinPeerThreshold { - log.Event(ctx, "bootstrapSkip", id) log.Debugf("%s core bootstrap skipped -- connected to %d (> %d) nodes", id, len(connected), cfg.MinPeerThreshold) return nil @@ -150,7 +146,6 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er // connect to a random susbset of bootstrap candidates randSubset := randomSubsetOfPeers(notConnected, numToDial) - defer log.EventBegin(ctx, "bootstrapStart", id).Done() log.Debugf("%s bootstrapping to %d nodes: %s", id, numToDial, randSubset) return bootstrapConnect(ctx, host, randSubset) } @@ -172,17 +167,14 @@ func bootstrapConnect(ctx context.Context, ph host.Host, peers []peer.AddrInfo) wg.Add(1) go func(p peer.AddrInfo) { defer wg.Done() - defer log.EventBegin(ctx, "bootstrapDial", ph.ID(), p.ID).Done() log.Debugf("%s bootstrapping to %s", ph.ID(), p.ID) ph.Peerstore().AddAddrs(p.ID, p.Addrs, peerstore.PermanentAddrTTL) if err := ph.Connect(ctx, p); err != nil { - log.Event(ctx, "bootstrapDialFailed", p.ID) log.Debugf("failed to bootstrap with %v: %s", p.ID, err) errs <- err return } - log.Event(ctx, "bootstrapDialSuccess", p.ID) log.Infof("bootstrapped with %v", p.ID) }(p) } diff --git a/core/corehttp/logs.go b/core/corehttp/logs.go index 387508b6d..99e8fa885 100644 --- a/core/corehttp/logs.go +++ b/core/corehttp/logs.go @@ -50,7 +50,7 @@ func LogOption() ServeOption { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) lwriter.WriterGroup.AddWriter(wnf) - log.Event(n.Context(), "log API client connected") + log.Event(n.Context(), "log API client connected") //nolint deprecated <-errs }) return mux, nil diff --git a/core/corerepo/gc.go b/core/corerepo/gc.go index c05b9f561..1fe888eb8 100644 --- a/core/corerepo/gc.go +++ b/core/corerepo/gc.go @@ -217,7 +217,6 @@ func (gc *GC) maybeGC(ctx context.Context, offset uint64) error { // Do GC here log.Info("Watermark exceeded. Starting repo GC...") - defer log.EventBegin(ctx, "repoGC").Done() if err := GarbageCollect(gc.Node, ctx); err != nil { return err diff --git a/fuse/readonly/readonly_unix.go b/fuse/readonly/readonly_unix.go index 47fdbc42a..9b315a016 100644 --- a/fuse/readonly/readonly_unix.go +++ b/fuse/readonly/readonly_unix.go @@ -20,7 +20,6 @@ import ( fs "bazil.org/fuse/fs" ipld "github.com/ipfs/go-ipld-format" logging "github.com/ipfs/go-log" - lgbl "github.com/libp2p/go-libp2p-loggables" ) var log = logging.Logger("fuse/ipfs") @@ -238,22 +237,11 @@ func (s *Node) Readlink(ctx context.Context, req *fuse.ReadlinkRequest) (string, } func (s *Node) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error { - c := s.Nd.Cid() - - // setup our logging event - lm := make(lgbl.DeferredMap) - lm["fs"] = "ipfs" - lm["key"] = func() interface{} { return c.String() } - lm["req_offset"] = req.Offset - lm["req_size"] = req.Size - defer log.EventBegin(ctx, "fuseRead", lm).Done() - r, err := uio.NewDagReader(ctx, s.Nd, s.Ipfs.DAG) if err != nil { return err } - o, err := r.Seek(req.Offset, io.SeekStart) - lm["res_offset"] = o + _, err = r.Seek(req.Offset, io.SeekStart) if err != nil { return err } @@ -266,7 +254,7 @@ func (s *Node) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadR default: return err } - lm["res_size"] = n + resp.Data = resp.Data[:n] return nil // may be non-nil / not succeeded } diff --git a/gc/gc.go b/gc/gc.go index 6b44771d4..436690900 100644 --- a/gc/gc.go +++ b/gc/gc.go @@ -40,11 +40,7 @@ type Result struct { func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn pin.Pinner, bestEffortRoots []cid.Cid) <-chan Result { ctx, cancel := context.WithCancel(ctx) - elock := log.EventBegin(ctx, "GC.lockWait") unlocker := bs.GCLock() - elock.Done() - elock = log.EventBegin(ctx, "GC.locked") - emark := log.EventBegin(ctx, "GC.mark") bsrv := bserv.New(bs, offline.Exchange(bs)) ds := dag.NewDAGService(bsrv) @@ -55,7 +51,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn defer cancel() defer close(output) defer unlocker.Unlock() - defer elock.Done() gcs, err := ColoredSet(ctx, pn, ds, bestEffortRoots, output) if err != nil { @@ -65,12 +60,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn } return } - emark.Append(logging.LoggableMap{ - "blackSetSize": fmt.Sprintf("%d", gcs.Len()), - }) - emark.Done() - esweep := log.EventBegin(ctx, "GC.sweep") - keychan, err := bs.AllKeysChan(ctx) if err != nil { select { @@ -113,10 +102,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn break loop } } - esweep.Append(logging.LoggableMap{ - "whiteSetSize": fmt.Sprintf("%d", removed), - }) - esweep.Done() if errors { select { case output <- Result{Error: ErrCannotDeleteSomeBlocks}: @@ -125,7 +110,6 @@ func GC(ctx context.Context, bs bstore.GCBlockstore, dstor dstore.Datastore, pn } } - defer log.EventBegin(ctx, "GC.datastore").Done() gds, ok := dstor.(dstore.GCDatastore) if !ok { return diff --git a/go.sum b/go.sum index f972e7ab4..bbb5a9baf 100644 --- a/go.sum +++ b/go.sum @@ -372,6 +372,7 @@ github.com/libp2p/go-libp2p v0.4.0 h1:nV2q3fdhL80OWtPyBrsoWKcw32qC4TbbR+iGjEOMRa github.com/libp2p/go-libp2p v0.4.0/go.mod h1:9EsEIf9p2UDuwtPd0DwJsAl0qXVxgAnuDGRvHbfATfI= github.com/libp2p/go-libp2p v0.4.2 h1:p0cthB0jDNHO4gH2HzS8/nAMMXbfUlFHs0jwZ4U+F2g= github.com/libp2p/go-libp2p v0.4.2/go.mod h1:MNmgUxUw5pMsdOzMlT0EE7oKjRasl+WyVwM0IBlpKgQ= +github.com/libp2p/go-libp2p v0.5.0/go.mod h1:Os7a5Z3B+ErF4v7zgIJ7nBHNu2LYt8ZMLkTQUB3G/wA= github.com/libp2p/go-libp2p v0.5.1 h1:kZ9jg+2B9IIptRcltBHKBrQdhXNNSrjCoztvrMx7tqI= github.com/libp2p/go-libp2p v0.5.1/go.mod h1:Os7a5Z3B+ErF4v7zgIJ7nBHNu2LYt8ZMLkTQUB3G/wA= github.com/libp2p/go-libp2p-autonat v0.0.2/go.mod h1:fs71q5Xk+pdnKU014o2iq1RhMs9/PMaG5zXRFNnIIT4= diff --git a/namesys/resolve/resolve.go b/namesys/resolve/resolve.go index 44f735a1f..5b5dc515e 100644 --- a/namesys/resolve/resolve.go +++ b/namesys/resolve/resolve.go @@ -7,15 +7,12 @@ import ( "strings" "github.com/ipfs/go-ipld-format" - logging "github.com/ipfs/go-log" "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" "github.com/ipfs/go-ipfs/namesys" ) -var log = logging.Logger("nsresolv") - // ErrNoNamesys is an explicit error for when an IPFS node doesn't // (yet) have a name system var ErrNoNamesys = errors.New( @@ -24,13 +21,8 @@ var ErrNoNamesys = errors.New( // ResolveIPNS resolves /ipns paths func ResolveIPNS(ctx context.Context, nsys namesys.NameSystem, p path.Path) (path.Path, error) { if strings.HasPrefix(p.String(), "/ipns/") { - evt := log.EventBegin(ctx, "resolveIpnsPath") - defer evt.Done() - // resolve ipns paths - // TODO(cryptix): we should be able to query the local cache for the path if nsys == nil { - evt.Append(logging.LoggableMap{"error": ErrNoNamesys.Error()}) return "", ErrNoNamesys } @@ -38,27 +30,23 @@ func ResolveIPNS(ctx context.Context, nsys namesys.NameSystem, p path.Path) (pat if len(seg) < 2 || seg[1] == "" { // just "/" without further segments err := fmt.Errorf("invalid path %q: ipns path missing IPNS ID", p) - evt.Append(logging.LoggableMap{"error": err}) return "", err } extensions := seg[2:] resolvable, err := path.FromSegments("/", seg[0], seg[1]) if err != nil { - evt.Append(logging.LoggableMap{"error": err.Error()}) return "", err } respath, err := nsys.Resolve(ctx, resolvable.String()) if err != nil { - evt.Append(logging.LoggableMap{"error": err.Error()}) return "", err } segments := append(respath.Segments(), extensions...) p, err = path.FromSegments("/", segments...) if err != nil { - evt.Append(logging.LoggableMap{"error": err.Error()}) return "", err } }