Skip to content

Commit 0bd7736

Browse files
committed
refactor: bitswap client - remove tracing
1 parent e9da747 commit 0bd7736

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

cmd/booster-bitswap/client.go

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import (
55
"crypto/rand"
66
"fmt"
77
"github.com/ipld/go-car/v2/blockstore"
8-
"net/http"
98
_ "net/http/pprof"
109
"sync/atomic"
1110
"time"
1211

13-
"github.com/filecoin-project/boost/tracing"
1412
lcli "github.com/filecoin-project/lotus/cli"
1513
"github.com/ipfs/go-bitswap/client"
1614
bsnetwork "github.com/ipfs/go-bitswap/network"
@@ -25,7 +23,6 @@ import (
2523
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
2624
quic "github.com/libp2p/go-libp2p/p2p/transport/quic"
2725
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
28-
"github.com/pkg/profile"
2926
"github.com/urfave/cli/v2"
3027
"golang.org/x/sync/errgroup"
3128
)
@@ -45,16 +42,6 @@ var fetchCmd = &cli.Command{
4542
Usage: "concurrent request limit - 0 means unlimited",
4643
Value: 10,
4744
},
48-
&cli.BoolFlag{
49-
Name: "tracing",
50-
Usage: "enables tracing of booster-bitswap calls",
51-
Value: false,
52-
},
53-
&cli.StringFlag{
54-
Name: "tracing-endpoint",
55-
Usage: "the endpoint for the tracing exporter",
56-
Value: "http://tempo:14268/api/traces",
57-
},
5845
},
5946
Action: func(cctx *cli.Context) error {
6047
if cctx.Args().Len() != 3 {
@@ -75,32 +62,8 @@ var fetchCmd = &cli.Command{
7562

7663
outputCarPath := cctx.Args().Get(2)
7764

78-
defer profile.Start(profile.TraceProfile, profile.ProfilePath(".")).Stop()
79-
80-
if cctx.Bool("pprof") {
81-
go func() {
82-
err := http.ListenAndServe("localhost:6065", nil)
83-
if err != nil {
84-
log.Error(err)
85-
}
86-
}()
87-
}
88-
8965
ctx := lcli.ReqContext(cctx)
9066

91-
// Instantiate the tracer and exporter
92-
if cctx.Bool("tracing") {
93-
tracingStopper, err := tracing.New("booster-bsclient", cctx.String("tracing-endpoint"))
94-
if err != nil {
95-
return fmt.Errorf("failed to instantiate tracer: %w", err)
96-
}
97-
log.Info("Tracing exporter enabled")
98-
99-
defer func() {
100-
_ = tracingStopper(ctx)
101-
}()
102-
}
103-
10467
// setup libp2p host
10568
log.Infow("generating libp2p key")
10669
privKey, _, err := crypto.GenerateECDSAKeyPair(rand.Reader)
@@ -132,13 +95,16 @@ var fetchCmd = &cli.Command{
13295
}
13396

13497
bsClient := client.New(ctx, net, bs)
98+
defer bsClient.Close()
13599
net.Start(bsClient)
136100

101+
connectStart := time.Now()
137102
log.Infow("connecting to server", "server", serverAddrInfo.String())
138103
err = host.Connect(ctx, *serverAddrInfo)
139104
if err != nil {
140105
return fmt.Errorf("connecting to %s: %w", serverAddrInfo, err)
141106
}
107+
log.Debugw("connected to server", "duration", time.Since(connectStart))
142108

143109
var throttle chan struct{}
144110
concurrency := cctx.Int("concurrency")
@@ -153,8 +119,11 @@ var fetchCmd = &cli.Command{
153119
return fmt.Errorf("getting blocks: %w", err)
154120
}
155121

156-
log.Infow("complete", "count", count, "size", size, "duration", time.Since(start))
157-
return nil
122+
log.Infow("fetch complete", "count", count, "size", size, "duration", time.Since(start))
123+
log.Info("finalizing")
124+
finalizeStart := time.Now()
125+
defer func() { log.Info("finalize complete", "duration", time.Since(finalizeStart)) }()
126+
return bs.Finalize()
158127
},
159128
}
160129

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ require (
9090
github.com/multiformats/go-multihash v0.2.1
9191
github.com/multiformats/go-varint v0.0.6
9292
github.com/open-rpc/meta-schema v0.0.0-20201029221707-1b72ef2ea333
93-
github.com/pkg/profile v1.2.1
9493
github.com/pressly/goose/v3 v3.5.3
9594
github.com/prometheus/client_golang v1.12.1
9695
github.com/raulk/clock v1.1.0

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
15391539
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
15401540
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
15411541
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1542-
github.com/pkg/profile v1.2.1 h1:F++O52m40owAmADcojzM+9gyjmMOY/T4oYJkgFDH8RE=
15431542
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
15441543
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
15451544
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

0 commit comments

Comments
 (0)