Skip to content

Commit b7a1ea9

Browse files
committed
1 parent 80cbca6 commit b7a1ea9

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

config/initializers/airbrake.rb

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# frozen_string_literal: true
2+
3+
# Airbrake is an online tool that provides robust exception tracking in your
4+
# Rails applications. In doing so, it allows you to easily review errors, tie an
5+
# error to an individual piece of code, and trace the cause back to recent
6+
# changes. Airbrake enables for easy categorization, searching, and
7+
# prioritization of exceptions so that when errors occur, your team can quickly
8+
# determine the root cause.
9+
#
10+
# Configuration details:
11+
# https://github.com/airbrake/airbrake-ruby#configuration
12+
if (project_id = ENV['AIRBRAKE_PROJECT_ID']) &&
13+
project_key = (ENV['AIRBRAKE_PROJECT_KEY'] || ENV['AIRBRAKE_API_KEY'])
14+
Airbrake.configure do |c|
15+
# You must set both project_id & project_key. To find your project_id and
16+
# project_key navigate to your project's General Settings and copy the
17+
# values from the right sidebar.
18+
# https://github.com/airbrake/airbrake-ruby#project_id--project_key
19+
c.project_id = project_id
20+
c.project_key = project_key
21+
22+
# Configures the root directory of your project. Expects a String or a
23+
# Pathname, which represents the path to your project. Providing this option
24+
# helps us to filter out repetitive data from backtrace frames and link to
25+
# GitHub files from our dashboard.
26+
# https://github.com/airbrake/airbrake-ruby#root_directory
27+
c.root_directory = Rails.root
28+
29+
# By default, Airbrake Ruby outputs to STDOUT. In Rails apps it makes sense
30+
# to use the Rails' logger.
31+
# https://github.com/airbrake/airbrake-ruby#logger
32+
c.logger = Airbrake::Rails.logger
33+
34+
# Configures the environment the application is running in. Helps the
35+
# Airbrake dashboard to distinguish between exceptions occurring in
36+
# different environments.
37+
# NOTE: This option must be set in order to make the 'ignore_environments'
38+
# option work.
39+
# https://github.com/airbrake/airbrake-ruby#environment
40+
c.environment = Rails.env
41+
42+
# Setting this option allows Airbrake to filter exceptions occurring in
43+
# unwanted environments such as :test. NOTE: This option *does not* work if
44+
# you don't set the 'environment' option.
45+
# https://github.com/airbrake/airbrake-ruby#ignore_environments
46+
c.ignore_environments = %w[test]
47+
48+
# A list of parameters that should be filtered out of what is sent to
49+
# Airbrake. By default, all "password" attributes will have their contents
50+
# replaced.
51+
# https://github.com/airbrake/airbrake-ruby#blocklist_keys
52+
c.blocklist_keys = [/password/i, /authorization/i]
53+
54+
# Alternatively, you can integrate with Rails' filter_parameters.
55+
# Read more: https://goo.gl/gqQ1xS
56+
# c.blocklist_keys = Rails.application.config.filter_parameters
57+
end
58+
59+
# A filter that collects request body information. Enable it if you are sure you
60+
# don't send sensitive information to Airbrake in your body (such as passwords).
61+
# https://github.com/airbrake/airbrake#requestbodyfilter
62+
# Airbrake.add_filter(Airbrake::Rack::RequestBodyFilter.new)
63+
64+
# Attaches thread & fiber local variables along with general thread information.
65+
# Airbrake.add_filter(Airbrake::Filters::ThreadFilter.new)
66+
67+
# Attaches loaded dependencies to the notice object
68+
# (under context/versions/dependencies).
69+
# Airbrake.add_filter(Airbrake::Filters::DependencyFilter.new)
70+
71+
# If you want to convert your log messages to Airbrake errors, we offer an
72+
# integration with the Logger class from stdlib.
73+
# https://github.com/airbrake/airbrake#logger
74+
# Rails.logger = Airbrake::AirbrakeLogger.new(Rails.logger)
75+
else
76+
Rails.logger.warn(
77+
"#{__FILE__}: Airbrake project id or project key is not set. " \
78+
"Skipping Airbrake configuration"
79+
)
80+
end

0 commit comments

Comments
 (0)