Skip to content

Commit 059e592

Browse files
authored
feat: add boostd-data metrics (#1784)
* add boostd-data metrics * go mod tidy * separate metrics * cleanup incorrect metrics * reduce metrics name size * add new dashboards * add some traces to boostd-daata * add API metrics to boostd * improve dashboard, remove older * remove info view name * use unique info view name * add storage to docker, fix tests * fix context * remove extra else and metric
1 parent b70bf8c commit 059e592

31 files changed

+8582
-5223
lines changed

cmd/boostd/run.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ package main
22

33
import (
44
"fmt"
5+
"net/http"
6+
_ "net/http/pprof"
7+
"time"
58

69
"github.com/filecoin-project/boost/api"
10+
"github.com/filecoin-project/boost/build"
11+
"github.com/filecoin-project/boost/metrics"
712
"github.com/filecoin-project/boost/node"
813
"github.com/filecoin-project/boost/node/modules/dtypes"
14+
"go.opencensus.io/stats"
15+
"go.opencensus.io/stats/view"
16+
"go.opencensus.io/tag"
917

1018
lapi "github.com/filecoin-project/lotus/api"
1119
"github.com/filecoin-project/lotus/api/v0api"
@@ -16,9 +24,6 @@ import (
1624
lcliutil "github.com/filecoin-project/lotus/cli/util"
1725
lotus_repo "github.com/filecoin-project/lotus/node/repo"
1826

19-
"net/http"
20-
_ "net/http/pprof"
21-
2227
"github.com/urfave/cli/v2"
2328
)
2429

@@ -35,6 +40,10 @@ var runCmd = &cli.Command{
3540
Name: "nosync",
3641
Usage: "dont wait for the full node to sync with the chain",
3742
},
43+
&cli.BoolFlag{
44+
Name: "no-metrics",
45+
Usage: "stops emitting information about the node as metrics (param is used by tests)",
46+
},
3847
},
3948
Action: func(cctx *cli.Context) error {
4049
if cctx.Bool("pprof") {
@@ -55,6 +64,23 @@ var runCmd = &cli.Command{
5564

5665
ctx := lcli.ReqContext(cctx)
5766

67+
if !cctx.Bool("no-metrics") {
68+
ctx, _ = tag.New(ctx,
69+
tag.Insert(metrics.Version, build.BuildVersion),
70+
tag.Insert(metrics.Commit, build.CurrentCommit),
71+
tag.Insert(metrics.NodeType, "boostd"),
72+
tag.Insert(metrics.StartedAt, time.Now().String()),
73+
)
74+
// Register all metric views
75+
if err = view.Register(
76+
metrics.DefaultViews...,
77+
); err != nil {
78+
log.Fatalf("Cannot register the view: %v", err)
79+
}
80+
// Set the metric to one so, it is published to the exporter
81+
stats.Record(ctx, metrics.BoostInfo.M(1))
82+
}
83+
5884
log.Debug("Checking full node version")
5985

6086
v, err := fullnodeApi.Version(ctx)

cmd/booster-bitswap/multiminer_retrieval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func runBoosterBitswap(ctx context.Context, repo string, minerApiInfo []string,
122122
"--api-fullnode=" + fullNodeApiInfo,
123123
"--api-lid=" + lidApiInfo,
124124
"--api-version-check=false",
125+
"--no-metrics",
125126
}
126127
for _, apiInfo := range minerApiInfo {
127128
args = append(args, "--api-storage="+apiInfo)

cmd/booster-bitswap/run.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"fmt"
55
"net/http"
66
_ "net/http/pprof"
7+
"time"
78

9+
"github.com/filecoin-project/boost/build"
810
"github.com/filecoin-project/boost/cmd/lib"
911
"github.com/filecoin-project/boost/cmd/lib/filters"
1012
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
@@ -16,6 +18,9 @@ import (
1618
"github.com/libp2p/go-libp2p/core/peer"
1719
"github.com/mitchellh/go-homedir"
1820
"github.com/urfave/cli/v2"
21+
"go.opencensus.io/stats"
22+
"go.opencensus.io/stats/view"
23+
"go.opencensus.io/tag"
1924
)
2025

2126
var runCmd = &cli.Command{
@@ -120,6 +125,10 @@ var runCmd = &cli.Command{
120125
Hidden: true,
121126
Value: true,
122127
},
128+
&cli.BoolFlag{
129+
Name: "no-metrics",
130+
Usage: "stops emitting information about the node as metrics (param is used by tests)",
131+
},
123132
},
124133
Action: func(cctx *cli.Context) error {
125134
if cctx.Bool("pprof") {
@@ -133,6 +142,22 @@ var runCmd = &cli.Command{
133142
}
134143

135144
ctx := lcli.ReqContext(cctx)
145+
if !cctx.Bool("no-metrics") {
146+
ctx, _ = tag.New(ctx,
147+
tag.Insert(metrics.Version, build.BuildVersion),
148+
tag.Insert(metrics.Commit, build.CurrentCommit),
149+
tag.Insert(metrics.NodeType, "booster-bitswap"),
150+
tag.Insert(metrics.StartedAt, time.Now().String()),
151+
)
152+
// Register all metric views
153+
if err := view.Register(
154+
metrics.DefaultViews...,
155+
); err != nil {
156+
log.Fatalf("Cannot register the view: %v", err)
157+
}
158+
// Set the metric to one so, it is published to the exporter
159+
stats.Record(ctx, metrics.BoostInfo.M(1))
160+
}
136161

137162
// Instantiate the tracer and exporter
138163
if cctx.Bool("tracing") {

cmd/booster-http/multiminer_retrieval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func runBoosterHttp(ctx context.Context, t *testing.T, minerApiInfo []string, fu
108108
"--api-fullnode=" + fullNodeApiInfo,
109109
"--api-lid=" + lidApiInfo,
110110
"--api-version-check=false",
111+
"--no-metrics",
111112
}, args...)
112113
for _, apiInfo := range minerApiInfo {
113114
args = append(args, "--api-storage="+apiInfo)

cmd/booster-http/run.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import (
88
"net/http"
99
_ "net/http/pprof"
1010
"os"
11+
"time"
1112

13+
"github.com/filecoin-project/boost/build"
1214
"github.com/filecoin-project/boost/cmd/lib"
1315
"github.com/filecoin-project/boost/cmd/lib/filters"
1416
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
@@ -24,6 +26,9 @@ import (
2426
"github.com/ipfs/go-cid"
2527
"github.com/mitchellh/go-homedir"
2628
"github.com/urfave/cli/v2"
29+
"go.opencensus.io/stats"
30+
"go.opencensus.io/stats/view"
31+
"go.opencensus.io/tag"
2732
)
2833

2934
const (
@@ -153,6 +158,10 @@ var runCmd = &cli.Command{
153158
Hidden: true,
154159
Value: true,
155160
},
161+
&cli.BoolFlag{
162+
Name: "no-metrics",
163+
Usage: "stops emitting information about the node as metrics (param is used by tests)",
164+
},
156165
},
157166
Action: func(cctx *cli.Context) error {
158167
servePieces := cctx.Bool("serve-pieces")
@@ -171,8 +180,26 @@ var runCmd = &cli.Command{
171180
}()
172181
}
173182

174-
// Connect to the local index directory service
175183
ctx := lcli.ReqContext(cctx)
184+
185+
if !cctx.Bool("no-metrics") {
186+
ctx, _ = tag.New(ctx,
187+
tag.Insert(metrics.Version, build.BuildVersion),
188+
tag.Insert(metrics.Commit, build.CurrentCommit),
189+
tag.Insert(metrics.NodeType, "booster-http"),
190+
tag.Insert(metrics.StartedAt, time.Now().String()),
191+
)
192+
// Register all metric views
193+
if err := view.Register(
194+
metrics.DefaultViews...,
195+
); err != nil {
196+
log.Fatalf("Cannot register the view: %v", err)
197+
}
198+
// Set the metric to one so, it is published to the exporter
199+
stats.Record(ctx, metrics.BoostInfo.M(1))
200+
}
201+
202+
// Connect to the local index directory service
176203
cl := bdclient.NewStore()
177204
defer cl.Close(ctx)
178205
err := cl.Dial(ctx, cctx.String("api-lid"))

docker/monitoring/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MONITORING_DATA=${HOME}/.boost-monitoring

docker/monitoring/docker-compose.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
volumes:
1313
- ./tempo-local.yaml:/etc/tempo.yaml
1414
- ./overrides.yaml:/etc/overrides.yaml
15-
- ./tempo-data:/tmp/tempo
15+
- ${MONITORING_DATA}/tempo-data:/tmp/tempo
1616
ports:
1717
- "14268:14268" # jaeger ingest
1818
restart: unless-stopped
@@ -44,6 +44,7 @@ services:
4444
command: [ "--config.file=/etc/prometheus.yaml" ]
4545
volumes:
4646
- ./${PROMETHEUS_CONFIG_FILE:-prometheus.yaml}:/etc/prometheus.yaml
47+
- ${MONITORING_DATA}/prometheus-data:/prometheus
4748
restart: unless-stopped
4849
ports:
4950
- "9190:9090"
@@ -56,6 +57,7 @@ services:
5657
#- "booster-http:host-gateway"
5758
#- "booster-bitswap:host-gateway"
5859
#- "lotus-miner:host-gateway"
60+
#- "boostd-data:host-gateway"
5961

6062
logging:
6163
driver: loki
@@ -76,7 +78,7 @@ services:
7678
#- GF_AUTH_DISABLE_LOGIN_FORM=true
7779
GF_AUTH_SIGV4_AUTH_ENABLED: true
7880
AWS_SDK_LOAD_CONFIG: true
79-
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/exported_dashboard.json"
81+
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/boostd.json"
8082
ports:
8183
- "3333:3000"
8284
restart: unless-stopped

0 commit comments

Comments
 (0)