From 93210061ad5eb73d3344bd3936287949f35da862 Mon Sep 17 00:00:00 2001 From: Ivan Daniluk Date: Tue, 3 Jul 2018 20:15:16 +0200 Subject: [PATCH] Add goroutines count to geth metrics (#1077) --- .../geth/0035-add_goroutines_metrics.patch | 23 +++++++++++++++++++ .../ethereum/go-ethereum/metrics/metrics.go | 5 ++++ 2 files changed, 28 insertions(+) create mode 100644 _assets/patches/geth/0035-add_goroutines_metrics.patch diff --git a/_assets/patches/geth/0035-add_goroutines_metrics.patch b/_assets/patches/geth/0035-add_goroutines_metrics.patch new file mode 100644 index 000000000..46b7fc3c4 --- /dev/null +++ b/_assets/patches/geth/0035-add_goroutines_metrics.patch @@ -0,0 +1,23 @@ +diff --git a/metrics/metrics.go b/metrics/metrics.go +index 2356f2b1..802f1363 100644 +--- a/metrics/metrics.go ++++ b/metrics/metrics.go +@@ -56,6 +56,7 @@ func CollectProcessMetrics(refresh time.Duration) { + memFrees := GetOrRegisterMeter("system/memory/frees", DefaultRegistry) + memInuse := GetOrRegisterMeter("system/memory/inuse", DefaultRegistry) + memPauses := GetOrRegisterMeter("system/memory/pauses", DefaultRegistry) ++ goroutines := GetOrRegisterGauge("system/goroutines", DefaultRegistry) + + var diskReads, diskReadBytes, diskWrites, diskWriteBytes Meter + if err := ReadDiskStats(diskstats[0]); err == nil { +@@ -83,6 +84,10 @@ func CollectProcessMetrics(refresh time.Duration) { + diskWrites.Mark(diskstats[location1].WriteCount - diskstats[location2].WriteCount) + diskWriteBytes.Mark(diskstats[location1].WriteBytes - diskstats[location2].WriteBytes) + } ++ ++ goroutines.Update(int64(runtime.NumGoroutine())) ++ + time.Sleep(refresh) + } ++ + } diff --git a/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go b/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go index 2356f2b14..802f13630 100644 --- a/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go +++ b/vendor/github.com/ethereum/go-ethereum/metrics/metrics.go @@ -56,6 +56,7 @@ func CollectProcessMetrics(refresh time.Duration) { memFrees := GetOrRegisterMeter("system/memory/frees", DefaultRegistry) memInuse := GetOrRegisterMeter("system/memory/inuse", DefaultRegistry) memPauses := GetOrRegisterMeter("system/memory/pauses", DefaultRegistry) + goroutines := GetOrRegisterGauge("system/goroutines", DefaultRegistry) var diskReads, diskReadBytes, diskWrites, diskWriteBytes Meter if err := ReadDiskStats(diskstats[0]); err == nil { @@ -83,6 +84,10 @@ func CollectProcessMetrics(refresh time.Duration) { diskWrites.Mark(diskstats[location1].WriteCount - diskstats[location2].WriteCount) diskWriteBytes.Mark(diskstats[location1].WriteBytes - diskstats[location2].WriteBytes) } + + goroutines.Update(int64(runtime.NumGoroutine())) + time.Sleep(refresh) } + }