Skip to content

Commit 98c2e19

Browse files
committed
booster-bitswap devnet and tracing (#796)
1 parent 85b7358 commit 98c2e19

File tree

7 files changed

+148
-1
lines changed

7 files changed

+148
-1
lines changed

cmd/booster-bitswap/remoteblockstore/remoteblockstore.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"context"
55
"errors"
66

7+
"github.com/filecoin-project/boost/tracing"
78
blocks "github.com/ipfs/go-block-format"
89
logging "github.com/ipfs/go-log/v2"
10+
"go.opentelemetry.io/otel/attribute"
911

1012
"github.com/ipfs/go-cid"
1113
blockstore "github.com/ipfs/go-ipfs-blockstore"
@@ -33,6 +35,10 @@ func NewRemoteBlockstore(api RemoteBlockstoreAPI) blockstore.Blockstore {
3335
}
3436

3537
func (ro *RemoteBlockstore) Get(ctx context.Context, c cid.Cid) (b blocks.Block, err error) {
38+
ctx, span := tracing.Tracer.Start(ctx, "rbls.get")
39+
defer span.End()
40+
span.SetAttributes(attribute.String("cid", c.String()))
41+
3642
log.Debugw("Get", "cid", c)
3743
data, err := ro.api.BlockstoreGet(ctx, c)
3844
log.Debugw("Get response", "cid", c, "error", err)
@@ -43,13 +49,21 @@ func (ro *RemoteBlockstore) Get(ctx context.Context, c cid.Cid) (b blocks.Block,
4349
}
4450

4551
func (ro *RemoteBlockstore) Has(ctx context.Context, c cid.Cid) (bool, error) {
52+
ctx, span := tracing.Tracer.Start(ctx, "rbls.has")
53+
defer span.End()
54+
span.SetAttributes(attribute.String("cid", c.String()))
55+
4656
log.Debugw("Has", "cid", c)
4757
has, err := ro.api.BlockstoreHas(ctx, c)
4858
log.Debugw("Has response", "cid", c, "has", has, "error", err)
4959
return has, err
5060
}
5161

5262
func (ro *RemoteBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
63+
ctx, span := tracing.Tracer.Start(ctx, "rbls.get_size")
64+
defer span.End()
65+
span.SetAttributes(attribute.String("cid", c.String()))
66+
5367
log.Debugw("GetSize", "cid", c)
5468
size, err := ro.api.BlockstoreGetSize(ctx, c)
5569
log.Debugw("GetSize response", "cid", c, "size", size, "error", err)

cmd/booster-bitswap/run.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
bclient "github.com/filecoin-project/boost/api/client"
1212
cliutil "github.com/filecoin-project/boost/cli/util"
1313
"github.com/filecoin-project/boost/cmd/booster-bitswap/remoteblockstore"
14+
"github.com/filecoin-project/boost/tracing"
1415
"github.com/filecoin-project/go-jsonrpc"
1516
lcli "github.com/filecoin-project/lotus/cli"
1617
"github.com/urfave/cli/v2"
@@ -35,6 +36,16 @@ var runCmd = &cli.Command{
3536
Usage: "the endpoint for the boost API",
3637
Required: true,
3738
},
39+
&cli.BoolFlag{
40+
Name: "tracing",
41+
Usage: "enables tracing of booster-bitswap calls",
42+
Value: false,
43+
},
44+
&cli.StringFlag{
45+
Name: "tracing-endpoint",
46+
Usage: "the endpoint for the tracing exporter",
47+
Value: "http://tempo:14268/api/traces",
48+
},
3849
},
3950
Action: func(cctx *cli.Context) error {
4051
if cctx.Bool("pprof") {
@@ -46,8 +57,22 @@ var runCmd = &cli.Command{
4657
}()
4758
}
4859

49-
// Connect to the Boost API
5060
ctx := lcli.ReqContext(cctx)
61+
62+
// Instantiate the tracer and exporter
63+
if cctx.Bool("tracing") {
64+
tracingStopper, err := tracing.New("booster-bitswap", cctx.String("tracing-endpoint"))
65+
if err != nil {
66+
return fmt.Errorf("failed to instantiate tracer: %w", err)
67+
}
68+
log.Info("Tracing exporter enabled")
69+
70+
defer func() {
71+
_ = tracingStopper(ctx)
72+
}()
73+
}
74+
75+
// Connect to the Boost API
5176
boostAPIInfo := cctx.String("api-boost")
5277
bapi, bcloser, err := getBoostAPI(ctx, boostAPIInfo)
5378
if err != nil {

docker/devnet/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ LOTUS_IMAGE=${DOCKER_USER}/lotus-dev:1.17.1-rc2
33
LOTUS_MINER_IMAGE=${DOCKER_USER}/lotus-miner-dev:1.17.1-rc2
44
BOOST_IMAGE=${DOCKER_USER}/boost-dev:dev
55
BOOSTER_HTTP_IMAGE=${DOCKER_USER}/booster-http-dev:dev
6+
BOOSTER_BITSWAP_IMAGE=${DOCKER_USER}/booster-bitswap-dev:dev
67
BOOST_GUI_IMAGE=${DOCKER_USER}/boost-gui:dev
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#########################################################################################
2+
## docker will invoke this file from ../../.. dir in order to access the code
3+
#########################################################################################
4+
ARG LOTUS_TEST_IMAGE=filecoin/lotus-test:latest
5+
FROM ${LOTUS_TEST_IMAGE} as lotus-dev
6+
#########################################################################################
7+
FROM golang:1.18-bullseye as builder
8+
9+
RUN apt update && apt install -y \
10+
build-essential \
11+
bzr pkg-config \
12+
clang \
13+
curl \
14+
gcc git \
15+
hwloc \
16+
jq \
17+
libhwloc-dev wget \
18+
mesa-opencl-icd \
19+
ocl-icd-opencl-dev
20+
21+
WORKDIR /go/src/
22+
23+
# copy src
24+
COPY . /go/src/
25+
26+
RUN make booster-bitswap debug
27+
#########################################################################################
28+
FROM ubuntu:20.04 as runner
29+
30+
RUN apt update && apt install -y \
31+
curl \
32+
hwloc \
33+
jq
34+
35+
ARG BUILD_VERSION=0.1
36+
37+
LABEL org.opencontainers.image.version=$BUILD_VERSION \
38+
org.opencontainers.image.authors="Boost Dev Team" \
39+
name="booster-bitswap-dev" \
40+
maintainer="Boost Dev Team" \
41+
vendor="Boost Dev Team" \
42+
version=$BUILD_VERSION \
43+
release=$BUILD_VERSION \
44+
summary="This image is used to host booster-bitswap-dev" \
45+
description="This image is used to host booster-bitswap-dev"
46+
47+
WORKDIR /app
48+
EXPOSE 8888
49+
50+
COPY --from=builder /go/src/booster-bitswap /usr/local/bin/
51+
COPY --from=builder /go/src/boostd /usr/local/bin/
52+
COPY --from=lotus-dev /usr/local/bin/lotus /usr/local/bin/
53+
COPY --from=lotus-dev /usr/local/bin/lotus-miner /usr/local/bin/
54+
## Fix missing lib libhwloc.so.5
55+
RUN ls -1 /lib/x86_64-linux-gnu/libhwloc.so.* | head -n 1 | xargs -n1 -I {} ln -s {} /lib/x86_64-linux-gnu/libhwloc.so.5
56+
57+
COPY docker/devnet/booster-bitswap/entrypoint.sh /app/
58+
59+
ENTRYPOINT ["./entrypoint.sh"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#####################################################################################
2+
service=$(docker_user)/booster-bitswap-dev
3+
version=dev
4+
########### DOCKER ##################################################################
5+
tag=$(service):$(version)
6+
rootdir=$(realpath .)
7+
8+
dbuild:
9+
docker build --build-arg LOTUS_TEST_IMAGE=$(lotus_test_image) \
10+
-t $(tag) -f Dockerfile.source $(rootdir)/../../../
11+
12+
dpush: dbuild
13+
docker push $(tag)
14+
15+
dscan: dbuild
16+
docker scan --accept-license $(tag)
17+
#####################################################################################
18+
.PHONY:
19+
dbuild dpush dscan
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
export FULLNODE_API_INFO=`lotus auth api-info --perm=admin | cut -f2 -d=`
5+
export MINER_API_INFO=`lotus-miner auth api-info --perm=admin | cut -f2 -d=`
6+
export BOOST_API_INFO=`boostd auth api-info --perm=admin | cut -f2 -d=`
7+
8+
echo $FULLNODE_API_INFO
9+
echo $MINER_API_INFO
10+
echo $BOOST_API_INFO
11+
12+
echo Starting booster-bitswap...
13+
exec booster-bitswap run --api-boost=$BOOST_API_INFO --tracing

docker/devnet/docker-compose.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ services:
8282
- ./data/lotus:/var/lib/lotus:ro
8383
- ./data/lotus-miner:/var/lib/lotus-miner:ro
8484

85+
booster-bitswap:
86+
container_name: booster-bitswap
87+
image: ${BOOSTER_BITSWAP_IMAGE}
88+
ports:
89+
- "8888:8888"
90+
environment:
91+
- BOOST_PATH=/var/lib/boost
92+
- LOTUS_PATH=/var/lib/lotus
93+
- LOTUS_MINER_PATH=/var/lib/lotus-miner
94+
restart: unless-stopped
95+
logging: *default-logging
96+
volumes:
97+
- ./data/boost:/var/lib/boost:ro
98+
- ./data/lotus:/var/lib/lotus:ro
99+
- ./data/lotus-miner:/var/lib/lotus-miner:ro
100+
85101
demo-http-server:
86102
container_name: demo-http-server
87103
image: nginx:1.23-alpine

0 commit comments

Comments
 (0)