Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add boostd-data metrics #1784

Merged
merged 14 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions cmd/boostd/run.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package main

import (
"context"
"fmt"
"net/http"
_ "net/http/pprof"
"time"

"github.com/filecoin-project/boost/api"
"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/metrics"
"github.com/filecoin-project/boost/node"
"github.com/filecoin-project/boost/node/modules/dtypes"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"

lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/api/v0api"
Expand All @@ -16,9 +25,6 @@ import (
lcliutil "github.com/filecoin-project/lotus/cli/util"
lotus_repo "github.com/filecoin-project/lotus/node/repo"

"net/http"
_ "net/http/pprof"

"github.com/urfave/cli/v2"
)

Expand All @@ -35,6 +41,10 @@ var runCmd = &cli.Command{
Name: "nosync",
Usage: "dont wait for the full node to sync with the chain",
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Bool("pprof") {
Expand All @@ -53,7 +63,27 @@ var runCmd = &cli.Command{
}
defer ncloser()

ctx := lcli.ReqContext(cctx)
ctxx := lcli.ReqContext(cctx)
var ctx context.Context

if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctxx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "boostd"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err = view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
} else {
ctx = ctxx
}

log.Debug("Checking full node version")

Expand Down
1 change: 1 addition & 0 deletions cmd/booster-bitswap/multiminer_retrieval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func runBoosterBitswap(ctx context.Context, repo string, minerApiInfo []string,
"--api-fullnode=" + fullNodeApiInfo,
"--api-lid=" + lidApiInfo,
"--api-version-check=false",
"--no-metrics",
}
for _, apiInfo := range minerApiInfo {
args = append(args, "--api-storage="+apiInfo)
Expand Down
32 changes: 31 additions & 1 deletion cmd/booster-bitswap/run.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package main

import (
"context"
"fmt"
"net/http"
_ "net/http/pprof"
"time"

"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/cmd/lib"
"github.com/filecoin-project/boost/cmd/lib/filters"
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
Expand All @@ -16,6 +19,9 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)

var runCmd = &cli.Command{
Expand Down Expand Up @@ -120,6 +126,10 @@ var runCmd = &cli.Command{
Hidden: true,
Value: true,
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
if cctx.Bool("pprof") {
Expand All @@ -132,7 +142,27 @@ var runCmd = &cli.Command{
}()
}

ctx := lcli.ReqContext(cctx)
ctxx := lcli.ReqContext(cctx)
var ctx context.Context

if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctxx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "booster-bitswap"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err := view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
} else {
ctx = ctxx
}

// Instantiate the tracer and exporter
if cctx.Bool("tracing") {
Expand Down
1 change: 1 addition & 0 deletions cmd/booster-http/multiminer_retrieval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func runBoosterHttp(ctx context.Context, t *testing.T, minerApiInfo []string, fu
"--api-fullnode=" + fullNodeApiInfo,
"--api-lid=" + lidApiInfo,
"--api-version-check=false",
"--no-metrics",
}, args...)
for _, apiInfo := range minerApiInfo {
args = append(args, "--api-storage="+apiInfo)
Expand Down
32 changes: 31 additions & 1 deletion cmd/booster-http/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"time"

"github.com/filecoin-project/boost/build"
"github.com/filecoin-project/boost/cmd/lib"
"github.com/filecoin-project/boost/cmd/lib/filters"
"github.com/filecoin-project/boost/cmd/lib/remoteblockstore"
Expand All @@ -24,6 +26,9 @@ import (
"github.com/ipfs/go-cid"
"github.com/mitchellh/go-homedir"
"github.com/urfave/cli/v2"
"go.opencensus.io/stats"
"go.opencensus.io/stats/view"
"go.opencensus.io/tag"
)

const (
Expand Down Expand Up @@ -153,6 +158,10 @@ var runCmd = &cli.Command{
Hidden: true,
Value: true,
},
&cli.BoolFlag{
Name: "no-metrics",
Usage: "stops emitting information about the node as metrics (param is used by tests)",
},
},
Action: func(cctx *cli.Context) error {
servePieces := cctx.Bool("serve-pieces")
Expand All @@ -171,8 +180,29 @@ var runCmd = &cli.Command{
}()
}

ctxx := lcli.ReqContext(cctx)
var ctx context.Context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but you don't need ctxx and you don't need else statement

Suggested change
ctxx := lcli.ReqContext(cctx)
var ctx context.Context
ctx := lcli.ReqContext(cctx)


if !cctx.Bool("no-metrics") {
ctx, _ = tag.New(ctxx,
tag.Insert(metrics.Version, build.BuildVersion),
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "booster-http"),
tag.Insert(metrics.StartedAt, time.Now().String()),
)
// Register all metric views
if err := view.Register(
metrics.DefaultViews...,
); err != nil {
log.Fatalf("Cannot register the view: %v", err)
}
// Set the metric to one so, it is published to the exporter
stats.Record(ctx, metrics.BoostInfo.M(1))
} else {
ctx = ctxx
}

// Connect to the local index directory service
ctx := lcli.ReqContext(cctx)
cl := bdclient.NewStore()
defer cl.Close(ctx)
err := cl.Dial(ctx, cctx.String("api-lid"))
Expand Down
1 change: 1 addition & 0 deletions docker/monitoring/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONITORING_DATA=${HOME}/.boost-monitoring
6 changes: 4 additions & 2 deletions docker/monitoring/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
volumes:
- ./tempo-local.yaml:/etc/tempo.yaml
- ./overrides.yaml:/etc/overrides.yaml
- ./tempo-data:/tmp/tempo
- ${MONITORING_DATA}/tempo-data:/tmp/tempo
ports:
- "14268:14268" # jaeger ingest
restart: unless-stopped
Expand Down Expand Up @@ -44,6 +44,7 @@ services:
command: [ "--config.file=/etc/prometheus.yaml" ]
volumes:
- ./${PROMETHEUS_CONFIG_FILE:-prometheus.yaml}:/etc/prometheus.yaml
- ${MONITORING_DATA}/prometheus-data:/prometheus
restart: unless-stopped
ports:
- "9190:9090"
Expand All @@ -56,6 +57,7 @@ services:
#- "booster-http:host-gateway"
#- "booster-bitswap:host-gateway"
#- "lotus-miner:host-gateway"
#- "boostd-data:host-gateway"

logging:
driver: loki
Expand All @@ -76,7 +78,7 @@ services:
#- GF_AUTH_DISABLE_LOGIN_FORM=true
GF_AUTH_SIGV4_AUTH_ENABLED: true
AWS_SDK_LOAD_CONFIG: true
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/exported_dashboard.json"
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/boostd.json"
ports:
- "3333:3000"
restart: unless-stopped
Expand Down
Loading