Class: Async::App::Metrics::RubyRuntimeMetricsCollector
- Inherits:
-
Object
- Object
- Async::App::Metrics::RubyRuntimeMetricsCollector
- Includes:
- Component
- Defined in:
- lib/async/app/metrics/ruby_runtime_metrics_collector.rb
Constant Summary collapse
- INTERVAL =
5
Instance Method Summary collapse
Methods included from Component
Instance Method Details
#metrics ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/async/app/metrics/ruby_runtime_metrics_collector.rb', line 15 def metrics fibers = ObjectSpace.each_object(Fiber) threads = ObjectSpace.each_object(Thread) ractors = ObjectSpace.each_object(Ractor) { ruby_fibers: { value: fibers.count }, ruby_fibers_active: { value: fibers.count(&:alive?) }, ruby_threads: { value: threads.count }, ruby_threads_active: { value: threads.count(&:alive?) }, ruby_ractors: { value: ractors.count }, ruby_memory: { value: GetProcessMem.new.bytes.to_s("F"), suffix: "bytes" } } end |
#run ⇒ Object
8 9 10 11 12 13 |
# File 'lib/async/app/metrics/ruby_runtime_metrics_collector.rb', line 8 def run Async::Timer.new(INTERVAL, run_on_start: true, on_error: ->(e) { warn(e) }) do bus.publish("metrics.updated", metrics) end info { "Started" } end |