forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CPU cycles and number of disk reads/writes metrics by pid (ava-la…
- Loading branch information
1 parent
b459661
commit 9e6bf96
Showing
4 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. | ||
// See the file LICENSE for licensing terms. | ||
|
||
package resource | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
"github.com/ava-labs/avalanchego/utils/wrappers" | ||
) | ||
|
||
type metrics struct { | ||
numCPUCycles *prometheus.GaugeVec | ||
numDiskReads *prometheus.GaugeVec | ||
numDiskReadBytes *prometheus.GaugeVec | ||
numDiskWrites *prometheus.GaugeVec | ||
numDiskWritesBytes *prometheus.GaugeVec | ||
} | ||
|
||
func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, error) { | ||
m := &metrics{ | ||
numCPUCycles: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "num_cpu_cycles", | ||
Help: "Total number of CPU cycles", | ||
}, | ||
[]string{"processID"}, | ||
), | ||
numDiskReads: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "num_disk_reads", | ||
Help: "Total number of disk reads", | ||
}, | ||
[]string{"processID"}, | ||
), | ||
numDiskReadBytes: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "num_disk_read_bytes", | ||
Help: "Total number of disk read bytes", | ||
}, | ||
[]string{"processID"}, | ||
), | ||
numDiskWrites: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "num_disk_writes", | ||
Help: "Total number of disk writes", | ||
}, | ||
[]string{"processID"}, | ||
), | ||
numDiskWritesBytes: prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: namespace, | ||
Name: "num_disk_write_bytes", | ||
Help: "Total number of disk write bytes", | ||
}, | ||
[]string{"processID"}, | ||
), | ||
} | ||
errs := wrappers.Errs{} | ||
errs.Add( | ||
registerer.Register(m.numCPUCycles), | ||
registerer.Register(m.numDiskReads), | ||
registerer.Register(m.numDiskReadBytes), | ||
registerer.Register(m.numDiskWrites), | ||
registerer.Register(m.numDiskWritesBytes), | ||
) | ||
return m, errs.Err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters