Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Monitor Your Ruby Application Using Scout APM

DZone's Guide to

Monitor Your Ruby Application Using Scout APM

Learn about using Scout, an Application Performance Management tool, to monitor your Ruby applications for performance issues.

· Performance Zone ·
Free Resource

Maintain Application Performance with real-time monitoring and instrumentation for any application. Learn More!

Do you remember the days of staring at the logs for hours to find a performance issue that the customer complained about? Are you a victim or unaware of memory bloat reasoning or any peculiar abnormalities? Is this API endpoint a culprit of system slowness? If you run into these scenarios, luckily, you landed in the right spot.

Before we start learning about Scout, let's dive deeper into APM (Application Performance Management/Monitoring). APM is any tool (for that matter, Scout) that will help monitor and optimize the application performance by collecting all kinds of data to mention some:

  • Web requests (client-server communication)
  • Transactional data at an individual code level
  • Database requests
  • Caching
  • API Endpoint calls
  • Error data
  • Log data

What Is Scout?

Image title

Scout is a lightweight application performance monitoring tool that analyzes app behavior to help you identify critical performance issues currently supporting Ruby, Elixir, and Python apps (only) at the time of writing. Scout can detect and identify:

  • Endpoint and network slowness
  • Slow requests like HTTP and Database Calls
  • N+1 queries
  • Memory allocation at the dyno and instance level
  • Memory leaks
  • Background job performance slowness
  • Transaction and response time traces
  • Usage by Url, IP, and hostnames
  • Throughput and response time
  • Code deployments

Installing Scout as a Ruby Agent

Scout Ruby agent is designed for Production ready lower overhead and transmit metrics over SSL. Scout Ruby agent currently supports Ruby 1.8+ and almost any application server. Let’s use Puma for simplicity since Puma is the default applications server on Rails 5.

Adding the gem to Gemfile

gem 'scout_apm', '~> 0.1.1'


Bundle the gemfile

bundle install


If you want to use it as an install:

gem install scout_apm -v 0.1.1


Download a customized config/scout_apm.yml file to add personalized scout account details. Here’s a detailed configuration reference:


Final Step: Deploy Your Code

Install Scout on Heroku

  1. Make sure the Scout gem is added to your gemfile and bundle install succeeds.
  2. Install or Add Heroku Addon:
    1. Heroku addons:create scout and replace the plan as per your pricing plan.
  3. Deploy your app to Heroku.

Understand Scout Monitoring

Scout Dashboard is an entry point for your application performance and analytic insights. Scout lets you pick any two indicators to show comparison and best of all scout lets you compare them at different time stamps and zoom and drag view. Scout enables you to embed the metric performance chart on another external webpage by merely adding iframe code snippet.

<iframe
  src="https://apm.scoutapp.com/apps/[your_app_id]/embeds/app_overview?p=throughput&s=response_time&time=d:30-min&key=[YOUR API KEY]"
  width="500" height="300"
  scrolling="no" frameborder="no">


Identifying Memory Leaks

Scout can easily point to a specific Controller Action, View Page or model that has more calls made and percentage of memory utilized. Watch out for tags with N+1 tag if any for a detailed query and time split and any significant memory increases or unnecessary object allocations

Dyno Usage

Scout provides memory usage stacked up by dynos including background schedulers. This helps to scale down or scale up the app dynos.

GitHub Integration

Easily integrate GitHub with a one-click OAuth setup:

GitHub integration can backtrace to any line in the code data including author and commit date making it easier to track down for any code bottlenecks.

Collect, analyze, and visualize performance data from mobile to mainframe with AutoPilot APM. Learn More!

Topics:
ruby ,rails ,ruby on rails ,logging ,apm ,performance ,monitoring

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}