Skip to content

Commit

Permalink
feat(libp2p): expose libp2p bandwidth metrics
Browse files Browse the repository at this point in the history
This exposes bandwidth metrics via async callback to avoid
allocating/reporting metrics on any hot-paths. I'm using open telemetry
as we've already setup a bridge for F3 and opencensus is deprecated in
favor of open telemetry (so we're going to slowly move over anyways).
  • Loading branch information
Stebalien committed Aug 16, 2024
1 parent 59fe7e3 commit cf17e13
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 19 deletions.
17 changes: 0 additions & 17 deletions chain/lf3/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import (
logging "github.com/ipfs/go-log/v2"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/host"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
"go.uber.org/fx"
"golang.org/x/xerrors"

Expand Down Expand Up @@ -53,20 +50,6 @@ type F3Params struct {

var log = logging.Logger("f3")

func init() {
// Set up otel to prometheus reporting so that F3 metrics are reported via lotus
// prometheus metrics. This bridge eventually gets picked up by opencensus
// exporter as HTTP handler. This by default registers an otel collector against
// the global prometheus registry. In the future, we should clean up metrics in
// Lotus and move it all to use otel. For now, bridge away.
if bridge, err := prometheus.New(); err != nil {
log.Errorf("could not create the otel prometheus exporter: %v", err)
} else {
provider := metric.NewMeterProvider(metric.WithReader(bridge))
otel.SetMeterProvider(provider)
}
}

func New(mctx helpers.MetricsCtx, lc fx.Lifecycle, params F3Params) (*F3, error) {

ds := namespace.Wrap(params.Datastore, datastore.NewKey("/f3"))
Expand Down
21 changes: 21 additions & 0 deletions metrics/otel_bridge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package metrics

import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/prometheus"
"go.opentelemetry.io/otel/sdk/metric"
)

func init() {
// Set up otel to prometheus reporting so that F3 metrics are reported via lotus
// prometheus metrics. This bridge eventually gets picked up by opencensus
// exporter as HTTP handler. This by default registers an otel collector against
// the global prometheus registry. In the future, we should clean up metrics in
// Lotus and move it all to use otel. For now, bridge away.
if bridge, err := prometheus.New(); err != nil {
log.Errorf("could not create the otel prometheus exporter: %v", err)
} else {
provider := metric.NewMeterProvider(metric.WithReader(bridge))
otel.SetMeterProvider(provider)
}
}
2 changes: 2 additions & 0 deletions node/modules/lp2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoremem"
routedhost "github.com/libp2p/go-libp2p/p2p/host/routed"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"go.opentelemetry.io/otel/metric"

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-splitstore)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deadlines)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-splitstore)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deadlines)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Build

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_cli)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_cli)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_block_hash)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_block_hash)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_dispute)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_dispute)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-supply)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-supply)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-manual_onboarding)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-manual_onboarding)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_hash_lookup)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_hash_lookup)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_terminate)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_terminate)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard_verified)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard_verified)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (gen-check)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_no_miner_storage)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_no_miner_storage)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_unseal)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_unseal)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_filter)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_filter)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gateway)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gateway)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-niporep_manual)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-niporep_manual)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_legacy_transactions)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_legacy_transactions)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-harmonydb)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-harmonydb)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_pledge)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_pledge)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_full)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_full)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_worker_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_worker_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-migration)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-migration)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sealing_resources)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sealing_resources)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_simple)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_simple)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deals_invalid_utf8_label)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deals_invalid_utf8_label)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-worker)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-worker)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-cli)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-cli)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_bytecode)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_bytecode)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-dup_mpool_messages)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-dup_mpool_messages)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_balance)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_balance)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_config)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_events)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_events)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_conformance)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_conformance)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_api)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-get_messages_in_ts)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-get_messages_in_ts)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_transactions)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_transactions)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_deploy)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_deploy)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_address)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_address)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lite_migration)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lite_migration)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gas_estimation)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gas_estimation)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_account_abstraction)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_account_abstraction)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_fee_history)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_fee_history)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lookup_robust_address)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lookup_robust_address)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_msg_uuid)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_msg_uuid)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mempool)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mempool)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-multisig)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-multisig)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-msgindex)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-msgindex)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_push_with_uuid)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_push_with_uuid)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-nonce)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-nonce)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-rest)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-rest)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-net)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-net)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-pending_deal_allocation)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-pending_deal_allocation)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-path_detach_redeclare)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-path_detach_redeclare)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_miner_collateral)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_miner_collateral)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-remove_verifreg_datacap)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-remove_verifreg_datacap)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_numassign)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_numassign)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-self_sent_txn)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-self_sent_txn)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-node)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-node)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-verifreg)

"go.opentelemetry.io/otel/metric" imported and not used

Check failure on line 19 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-verifreg)

"go.opentelemetry.io/otel/metric" imported and not used
"go.uber.org/fx"

"github.com/filecoin-project/lotus/build"
Expand Down Expand Up @@ -64,6 +65,7 @@ func Host(mctx helpers.MetricsCtx, buildVersion build.BuildVersion, lc fx.Lifecy

lc.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
_ = registration.Unregister()

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deadlines)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-splitstore)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-splitstore)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deadlines)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Build

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_cli)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_cli)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_block_hash)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_block_hash)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_dispute)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_dispute)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-supply)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-supply)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-manual_onboarding)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-manual_onboarding)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_hash_lookup)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_hash_lookup)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_terminate)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_terminate)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-paych_api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard_verified)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard_verified)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (gen-check)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_no_miner_storage)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_no_miner_storage)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_unseal)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_unseal)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_filter)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_filter)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gateway)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gateway)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-direct_data_onboard)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-niporep_manual)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-niporep_manual)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_legacy_transactions)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_legacy_transactions)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-harmonydb)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-harmonydb)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_pledge)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_pledge)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_full)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_full)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_worker_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost_worker_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-migration)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-migration)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sealing_resources)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sealing_resources)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_simple)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_import_simple)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-wdpost)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deals_invalid_utf8_label)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-deals_invalid_utf8_label)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-worker)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-worker)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

undefined: registration (typecheck)

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

undefined: registration) (typecheck)

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Check (lint-all)

undefined: registration) (typecheck)

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-cli)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-cli)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_bytecode)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_bytecode)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-dup_mpool_messages)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-dup_mpool_messages)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_balance)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_balance)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_config)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_events)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_events)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_conformance)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_conformance)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_api)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-get_messages_in_ts)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-get_messages_in_ts)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_transactions)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_transactions)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_deploy)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_deploy)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_address)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-fevm_address)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lite_migration)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lite_migration)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gas_estimation)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-gas_estimation)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_account_abstraction)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_account_abstraction)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_fee_history)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-eth_fee_history)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lookup_robust_address)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-lookup_robust_address)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_msg_uuid)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_msg_uuid)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mempool)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mempool)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-multisig)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-multisig)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-msgindex)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-msgindex)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_push_with_uuid)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-mpool_push_with_uuid)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-nonce)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-nonce)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-rest)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-rest)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-net)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-net)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-pending_deal_allocation)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-pending_deal_allocation)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-path_detach_redeclare)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-path_detach_redeclare)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_miner_collateral)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_miner_collateral)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-remove_verifreg_datacap)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-remove_verifreg_datacap)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_numassign)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-sector_numassign)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-self_sent_txn)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-self_sent_txn)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-node)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (unit-node)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-verifreg)

undefined: registration

Check failure on line 68 in node/modules/lp2p/host.go

View workflow job for this annotation

GitHub Actions / Test (itest-verifreg)

undefined: registration
return h.Close()
},
})
Expand Down
30 changes: 30 additions & 0 deletions node/modules/lp2p/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package lp2p

import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
)

var otelmeter = otel.Meter("libp2p")

var attrPeerID = attribute.Key("peer")
var attrProtocolID = attribute.Key("protocol")
var attrDirectionInbound = attribute.String("direction", "inbound")
var attrDirectionOutbound = attribute.String("direction", "outbound")

var otelmetrics = struct {
bandwidth metric.Int64ObservableGauge
}{
bandwidth: must(otelmeter.Int64ObservableGauge("libp2p_bandwidth",
metric.WithDescription("Libp2p stream traffic."),
metric.WithUnit("By"),
)),
}

func must[T any](v T, err error) T {
if err != nil {
panic(err)
}
return v
}
29 changes: 27 additions & 2 deletions node/modules/lp2p/transport.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package lp2p

import (
"context"

"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/peer"
noise "github.com/libp2p/go-libp2p/p2p/security/noise"
tls "github.com/libp2p/go-libp2p/p2p/security/tls"
libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic"
"go.opentelemetry.io/otel/metric"
"go.uber.org/fx"
)

var DefaultTransports = simpleOpt(libp2p.DefaultTransports)
Expand All @@ -31,8 +36,28 @@ func Security(enabled, preferTLS bool) interface{} {
}
}

func BandwidthCounter() (opts Libp2pOpts, reporter metrics.Reporter) {
func BandwidthCounter(lc fx.Lifecycle, id peer.ID) (opts Libp2pOpts, reporter metrics.Reporter, err error) {
reporter = metrics.NewBandwidthCounter()
opts.Opts = append(opts.Opts, libp2p.BandwidthReporter(reporter))
return opts, reporter

// Register it with open telemetry. We report by-callback instead of implementing a custom
// bandwidth counter to avoid allocating every time we read/write to a stream (and to stay
// out of the hot path).
peerIdAttr := attrPeerID.String(id.String())
registration, err := otelmeter.RegisterCallback(func(ctx context.Context, obs metric.Observer) error {
for p, bw := range reporter.GetBandwidthByProtocol() {
protoAttr := attrProtocolID.String(string(p))
obs.ObserveInt64(otelmetrics.bandwidth, bw.TotalOut,
metric.WithAttributes(peerIdAttr, protoAttr, attrDirectionOutbound))
obs.ObserveInt64(otelmetrics.bandwidth, bw.TotalIn,
metric.WithAttributes(peerIdAttr, protoAttr, attrDirectionInbound))
}
return nil
}, otelmetrics.bandwidth)
if err != nil {
return Libp2pOpts{}, nil, err
}
lc.Append(fx.StopHook(registration.Unregister))

return opts, reporter, nil
}

0 comments on commit cf17e13

Please sign in to comment.