Cloud Trace API - Class Google::Cloud::Trace::Railtie (v0.44.0)

Reference documentation and code samples for the Cloud Trace API class Google::Cloud::Trace::Railtie.

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:

ruby 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 Instrumentation Guide and 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.

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

Inherits

  • Rails::Railtie

Constants

DEFAULT_NOTIFICATIONS

value: [ "sql.active_record", "render_template.action_view", "send_file.action_controller", "send_data.action_controller", "deliver.action_mailer" ].freeze
The default list of ActiveSupport notification types to include in traces.