Documentation forAppOptics

Code profiling (legacy agent)

Code profiling can give extra insight into code level execution time that is otherwise not captured in traces. See Code Profiling for general information.

appoptics_apm gem version 4.13.0 or later is required for profiling.

The Ruby code profiler is a sampling code profiler and is based on the stackprof profiler.

The profiler shows pure Ruby methods, but not methods that are implemented in C. Starting with Ruby 3.0, the profiler will show the class name and <cfunc> when a method implemented in C is called.

While Ruby 2.5++ and 3.0.+ are supported, the combination of Ruby 3.0.+ and Puma currently does not generate useful profiling. If this is your use case, e-mail AppOptics support and let us know so we can prioritize future enhancements.

Configuration

Enable Profiling

Code profiling is disabled by default because it incurs overhead. To enable code profiling, modify the Configuration File so AppOpticsAPM::Config[:profiling] is set to :enabled.

Setting the Profiling Interval

The length in milliseconds of the profiling interval can be set with AppOpticsAPM::Config[:profiling_interval]. The default profiling interval is 10ms. Values as small as 1ms and as large as 100ms are accepted, though it is recommended not to sample at less than 5ms.

If a trace is shorter than the profiling interval it will not be profiled.

Types of Percentages shown

A majority of the Ruby code profiling data shown in AppOptics will be a cascading representation of methods calls. In addition, there may also be percentages for GARBAGE COLLECTION, OTHER THREADS, and UNKNOWN.

GARBAGE COLLECTION

This represents the time Ruby spent garbage collecting.

OTHER THREADS

The AppOptics Ruby code profiler can sample multiple threads. However, since Ruby only runs a single thread at a time the profiler will label the percentage of time spent in other threads during a trace with OTHER THREADS.

UNKNOWN

UNKNOWN accounts for situations where the agent failed to obtain snapshots on the given interval. Many different conditions, including a high CPU load, can trigger missing snapshots.