RoRvsWild

Requests performances monitoring

How to measure any section of code, and configure RoRvsWild to ignore some requests.

Measure any section of code

RorVsWild measures a lot of events such as SQL queries and views rendering. But it might not be enough for you. There is a solution to measure any section of code to help you find the most hidden bottlenecks:

# Measure a code given as a string
RorVsWild.measure("bubble_sort(array)")

# Measure a code given as a block
RorVsWild.measure { bubble_sort(array) }

# Measure a code given as a block with an optional description
RorVsWild.measure("Optional description") { bubble_sort(array) }

For each custom measure, a section is added with the file name and line number where it has been called.

Server-Timing header (version >= 1.7.0)

Server-Timing is a HTTP header to provide metrics about backend runtimes. The goal is to let you find bottlenecks directly from the browser’s inspector (click on the request and then timing/delay tab). Due to the limitation of the header, it contains less details than the RorVsWild’s interface.

It’s disabled by default, and it has to be enabled for each request. You will probably prefer to limit to privileged users in production to prevent from exposing sensitive data. Here is a good default setup, to enable server timing in all environments and only for admins in production:

class ApplicationController < ActionController::Base
  before_action :expose_server_timing_header

  def expose_server_timing_header
    # Assuming there are current_user and admin? methods
    RorVsWild.send_server_timing = !Rails.env.production? ||
      current_user.try(:admin?)
  end
end

Ignoring controllers and actions

Sometimes, you just don’t want to know. You can either exclude endpoints with their controller and action names or with a regex to exclude many endpoints at once:

# config/rorvswild.yml
production:
  api_key: YOUR_API_KEY
    ignore_requests:
      - SecretController#index
      - !ruby/regexp /AnotherSecretController/ # Skip the entire controller

Sampling requests (version >= 1.7.0)

If your application handles a lot of trafic, you can sample requests to lower your monitoring bill.

  # config/rorvswild.yml
  production:
    api_key: API_KEY
    job_sampling_rate: 0.5 # 50% of jobs are sent
    request_sampling_rate: 0.25 # 25% of requests are sent

Need help?

Contact us.

RorVsWild monitors your Ruby on Rails applications.

Try for free
RoRvsWild Ruby error details