Add goroutines count to geth metrics (#1077)

This commit is contained in:
Ivan Daniluk 2018-07-03 20:15:16 +02:00 committed by GitHub
parent f19e3eae8e
commit 93210061ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -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)
}
+
}

View File

@ -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)
}
}