Raygun Application Performance Monitoring

Ruby Profiler for Raygun Application Performance Monitoring.

Distributed as a precompiled native gem.

Supported platforms

  • x86-mingw32

  • x64-mingw32

  • x86-linux

  • x86_64-linux

  • universal-darwin

Contact us to support other platforms.

Supported Ruby versions

The profiler only supports CRuby, also known as Matz’s Ruby Interpreter (MRI).

  • 2.5.x

  • 2.6.x

  • 2.7.x

Contact us to support other Ruby versions.

Agent Setup

The Profiler needs to be able to access the Raygun Agent over UDP.

The RAYGUN_AGENT_TOKEN needs to be supplied as an argument and is available under “Application Settings” at the Raygun Application Performance Monitoring UI

To launch Raygun Agent using docker

docker pull raygunowner/raygun-apm
docker run -v raygun-agent:/usr/share/Raygun -e "RAYGUN_AGENT_TOKEN=<token>" -p 2790:2790 -p 2788:2788 -p 2799:2799/udp -it raygunowner/raygun-apm:latest

Ruby on Rails

For Rails support see documentation of the railgun-apm-rails gem.

Profiler Setup

Include the gem in your Gemfile

gem 'raygun-apm'

Run bundle to install the gem.

Alternatively install using rubygems gem install raygun-apm.

Standalone ruby script / custom framework

For standalone scripts, context start-end needs to be marked specifically and optionally extended events can be called.

#!/usr/bin/env ruby
require 'raygun/apm'

class Hello
  def rdoc
    sleep 0.5
  end
end

tracer = Raygun::Apm::Tracer.new
tracer.udp_sink!
tracer.process_started
tracer.start_trace
Hello.new.rdoc
tracer.end_trace
tracer.process_ended

Extended events can be sent where appropiate

HTTP incoming event

event = Raygun::Apm::Event::HttpIn.new
event[:pid] = Process.pid
event[:tid] = 0
event[:timestamp] = tracer.now
event[:url] = 'https://google.com/'
event[:verb] = 'GET'
event[:status] = 200
event[:duration] = 1000  
tracer.emit(event)

SQL query

event = Raygun::Apm::Event::Sql.new
event[:pid] = Process.pid
event[:tid] = 0
event[:timestamp] = tracer.now
event[:provider] = 'postgres'
event[:host] = 'localhost'
event[:database] = 'rails'
event[:query] = 'SELECT * from FOO;'
event[:duration] = 1000
tracer.emit(event)