Class: Google::Cloud::Trace::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/google/cloud/trace/rails.rb

Overview

Rails integration for Stackdriver Trace

This Railtie is a drop-in Stackdriver Trace instrumentation plugin for Ruby on Rails applications. If present, it automatically instruments your Rails app to record performance traces and cause them to appear on your Stackdriver console.

Installation

To install this plugin, the gem google-cloud-trace must be in your Gemfile. You also must add the following line to your application.rb file:

require "google/cloud/trace/rails"

If you include the stackdriver gem in your Gemfile, the above is done for you automatically, and you do not need to edit your application.rb.

Configuration

See the Configuration Guide on how to configure the Railtie and Middleware.

Measuring custom functionality

To add a custom measurement to a request trace, use the classes provided in this library. Below is an example to get you started.

class MyController < ApplicationController
  def index
    Google::Cloud::Trace.in_span "Sleeping on the job!" do
      sleep rand
    end
    render plain: "Hello World!"
  end
end

Constant Summary collapse

DEFAULT_NOTIFICATIONS =

The default list of ActiveSupport notification types to include in traces.

[
  "sql.active_record",
  "render_template.action_view",
  "send_file.action_controller",
  "send_data.action_controller",
  "deliver.action_mailer"
].freeze