Skip to content

Commit

Permalink
fix(tracing): remove event tracing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Stebalien committed Jan 29, 2020
1 parent a53d480 commit 906f45e
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 52 deletions.
8 changes: 0 additions & 8 deletions core/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion core/corehttp/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion core/corerepo/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 2 additions & 14 deletions fuse/readonly/readonly_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down
16 changes: 0 additions & 16 deletions gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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}:
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 0 additions & 12 deletions namesys/resolve/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -24,41 +21,32 @@ 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
}

seg := p.Segments()

if len(seg) < 2 || seg[1] == "" { // just "/<protocol/>" 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
}
}
Expand Down

0 comments on commit 906f45e

Please sign in to comment.