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(dot/babe) implement block production time metric #1648

Merged
merged 16 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 10 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
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.7'

services:
noot marked this conversation as resolved.
Show resolved Hide resolved
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- 9090:9090
restart: always
1 change: 0 additions & 1 deletion dot/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const (

// CollectProcessMetrics periodically collects various metrics about the running process.
func CollectProcessMetrics() {
metrics.Enabled = true
// Create the various data collectors
cpuStats := make([]*metrics.CPUStats, 2)
memStats := make([]*runtime.MemStats, 2)
Expand Down
9 changes: 9 additions & 0 deletions dot/network/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"time"

ethmetrics "github.com/ethereum/go-ethereum/metrics"
badger "github.com/ipfs/go-ds-badger2"
libp2phost "github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
Expand All @@ -31,6 +32,11 @@ import (
"github.com/libp2p/go-libp2p-kad-dht/dual"
)

const (
checkPeerCountMetrics = "gossamer/network/peer_count"
peersStoreMetrics = "gossamer/network/peerstore_count"
)

var (
startDHTTimeout = time.Second * 10
initialAdvertisementTimeout = time.Millisecond
Expand Down Expand Up @@ -115,6 +121,9 @@ func (d *discovery) stop() error {
return nil
}

ethmetrics.Unregister(checkPeerCountMetrics)
ethmetrics.Unregister(peersStoreMetrics)
Comment on lines +124 to +125
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Member Author

Choose a reason for hiding this comment

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

this allows the unused metrics to be collected by the gc


return d.dht.Close()
}

Expand Down
1 change: 1 addition & 0 deletions dot/network/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,5 @@ func TestBeginDiscovery_ThreeNodes(t *testing.T) {
// assert B and C can discover each other
addrs := nodeB.host.h.Peerstore().Addrs(nodeC.host.id())
require.NotEqual(t, 0, len(addrs))

}
1 change: 0 additions & 1 deletion dot/network/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ func (s *Service) Start() error {
}

func (s *Service) collectNetworkMetrics() {
metrics.Enabled = true
for {
peerCount := metrics.GetOrRegisterGauge("network/node/peerCount", metrics.DefaultRegistry)
totalConn := metrics.GetOrRegisterGauge("network/node/totalConnection", metrics.DefaultRegistry)
Expand Down
1 change: 1 addition & 0 deletions dot/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func NewNode(cfg *Config, ks *keystore.GlobalKeystore, stopFunc func()) (*Node,
}

func publishMetrics(cfg *Config) {
metrics.Enabled = true
address := fmt.Sprintf("%s:%d", cfg.RPC.Host, cfg.Global.MetricsPort)
log.Info("Enabling stand-alone metrics HTTP endpoint", "address", address)
setupMetricsServer(address)
Expand Down
19 changes: 7 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ require (
github.com/centrifuge/go-substrate-rpc-client/v2 v2.0.1
github.com/chyeh/pubip v0.0.0-20170203095919-b7e679cf541c
github.com/cosmos/go-bip39 v1.0.0
github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect
github.com/dgraph-io/badger/v2 v2.2007.2
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de
github.com/disiqueira/gotree v1.0.0
github.com/docker/docker v1.13.1
github.com/elastic/gosigar v0.14.0 // indirect
github.com/ethereum/go-ethereum v1.9.7
github.com/go-playground/validator/v10 v10.4.1
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7 // indirect
github.com/golang/protobuf v1.4.3
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 // indirect
github.com/google/uuid v1.1.5 // indirect
Expand All @@ -34,13 +32,12 @@ require (
github.com/jpillora/backoff v1.0.0 // indirect
github.com/jpillora/ipfilter v1.2.2
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/libp2p/go-libp2p v0.12.0
github.com/libp2p/go-libp2p-core v0.7.0
github.com/libp2p/go-libp2p v0.14.2
github.com/libp2p/go-libp2p-core v0.8.5
github.com/libp2p/go-libp2p-discovery v0.5.0
github.com/libp2p/go-libp2p-kad-dht v0.11.1
github.com/libp2p/go-libp2p-peerstore v0.2.6
github.com/libp2p/go-libp2p-peerstore v0.2.7
github.com/libp2p/go-libp2p-secio v0.2.2
github.com/libp2p/go-sockaddr v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.11 // indirect
github.com/multiformats/go-multiaddr v0.3.1
Expand All @@ -53,13 +50,11 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/urfave/cli v1.20.0
github.com/wasmerio/go-ext-wasm v0.3.2-0.20200326095750-0a32be6068ec
go.opencensus.io v0.22.5 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/protobuf v1.25.0
google.golang.org/protobuf v1.26.0-rc.1
)

go 1.15
Loading