Class: PrometheusExporter::Ext::Instrumentation::ProcCpu
- Inherits:
-
PeriodicStats
- Object
- BaseStats
- PeriodicStats
- PrometheusExporter::Ext::Instrumentation::ProcCpu
- Defined in:
- lib/prometheus_exporter/ext/instrumentation/proc_cpu.rb
Class Method Summary collapse
Instance Method Summary collapse
- #collect ⇒ Object
-
#initialize ⇒ ProcCpu
constructor
A new instance of ProcCpu.
Methods inherited from PeriodicStats
Methods inherited from BaseStats
Constructor Details
#initialize ⇒ ProcCpu
Returns a new instance of ProcCpu.
18 19 20 21 |
# File 'lib/prometheus_exporter/ext/instrumentation/proc_cpu.rb', line 18 def initialize(...) @last_cpu_time = 0.0 super end |
Class Method Details
.start(type:, labels: {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/prometheus_exporter/ext/instrumentation/proc_cpu.rb', line 11 def start(type:, labels: {}, **) labels = labels.merge(type:) super(labels:, **) end |
Instance Method Details
#collect ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/prometheus_exporter/ext/instrumentation/proc_cpu.rb', line 23 def collect stat = PrometheusExporter::Ext::ProcSelfStat.get collect_data( labels: { pid: stat.pid, hostname: ::PrometheusExporter.hostname }, usage_seconds_total: stat.cpu_time - @last_cpu_time ) @last_cpu_time = stat.cpu_time end |