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

0.46.0 (latest) 0.45.0 0.44.1 0.43.0 0.42.2 0.41.4 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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-trace/latest/INSTRUMENTATION "Instrumentation Guide") and
[Configuration
Guide](https://googleapis.dev/ruby/stackdriver/latest/file.INSTRUMENTATION_CONFIGURATION.html)
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.