Skip to content

Treblle with Ruby on Rails

Requirements

  • Ruby 2.0+
  • Ruby on Rails 6.1+

Installation

Add the gem to your Gemfile:

# Gemfile
gem "treblle", "~> 2.0"

Then add following line to config/application.rb, or if you want to include it to specific environment only, then e.g. config/environments/development.rb which registers Treblle middleware.

config.middleware.use(Treblle)

You can then configure the gem:

config/initializers/treblle.rb
Treblle.configure do |config|
config.api_key = ENV.fetch('TREBLLE_API_KEY')
config.project_id = ENV.fetch('TREBLLE_PROJECT_ID')
config.enabled_environments = %w[staging development]
config.sensitive_attrs = %w[top_secret_custom_attribute password_digest]
config.restricted_endpoints = %w[/api/users /api/v2/*]
config.whitelisted_endpoints = %w[/api/]
end

You can use any of the configuration options below:

OptionDescription
config.api_key(required) Valid API key obtained during registration on treblle.com.
config.project_id(required) Valid Project ID obtained after creating a new project on treblle.com.
config.enabled_environments(required) Enables monitoring on specified environments.
config.sensitive_attrs(optional) Mask additional attributes.
config.restricted_endpoints(optional) Routes that you don’t want to monitor.
config.whitelisted_endpoints(optional) Routes that you want to monitor, by default /api/.