Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RubyKaigi 2024 LT: Visualize the internal state of ruby processes in Real-Time

RubyKaigi 2024 LT: Visualize the internal state of ruby processes in Real-Time

MetricsMonitor is a gem that visualizes the internal metrics of ruby processes.

What are the CPU utilization trends for each process of a program that launches multiple processes? What is the timing of GC execution and how is the memory usage trending? How many Ruby objects of what class are being generated inside each process?

Therefore, I created MetricsMonitor, a tool that attaches directly to a running Ruby program and can observe its internal state. By simply embedding this tool in your Ruby program, you can visualize and observe the internal state of your program. This tool has been instrumental in visualizing and resolving real problems, such as bloated memory usage in large applications.

In this talk, I will show how my MetricsMonitor visualizes the internal state of a Ruby program and how I find problems in Ruby programs based on that visualization.

This talk will be enjoyable for Ruby developers who are looking to gain deeper insights about their Ruby applications.

hogelog

May 16, 2024
Tweet

More Decks by hogelog

Other Decks in Programming

Transcript

  1. STORES 株式会社 Visualize the internal state of Ruby processes in

    Real-Time @hogelog (Sunao Komuro) RubyKaigi 2024 Lightning Talk STORES, Inc.
  2. Who is hogelog? 2 - @hogelog (GitHub, Twitter, …) -

    小室 直 (Sunao Komuro) - Software Engineer at STORES, Inc. - I like Ruby and programming
  3. Why I created metrics_monitor 5 - There are some Ruby

    programs out there with issues - CPU, Memory, ... - Some I wrote myself, and some that were already around - Everyone wants to solve problems
  4. Finding Ruby program issues 6 - Profiler? - pf2, ruby-prof,

    stackprof, memory_profiler, … excellent! - APM? - Datadog, Scout APM, … great! - But, I wanted an easier way to observe
  5. My true trigger 7 - Frankly, I wanted VisualVM for

    Ruby - https://visualvm.github.io/ -
  6. 9

  7. Ruby Program Child Process Main Process metrics_monitor metrics_monitor components 11

    - Components: Collector, Visualizer Visualizer Main Collector Collector Child Collector … … Pipe Target Program HTTP
  8. Custom Collector 12 class RandomCollector < MetricsMonitor::Collector::CollectorBase def self.default_options =

    { enabled: true, interval: 5_000 } def meta_data = { title: "Random", monitors: [{ key: :random, title: "Random values", type: :chart, mode: :line }], data: { random: { mode: "append" } }, } def data = { random: rand } end
  9. Summary 18 - I created metrics_monitor gem - Plug in

    and visualize program's internal state - Set up a simple collector to interactively visualize - More casual research options before serious analysis - Happy ruby programming, profiling, monitoring, analysis!
  10. Future work 19 - Attaching without `require` - More extensive

    visualizer - Improving the overloaded collectors - Dynamically configure collectors from the view - Overall improvements