googleads
How To Integrate Rails Application With Sentry - Rails Error Tracking
preloder
Ruby on Rails Web Development

How To Integrate Rails Application With Sentry – Rails Error Tracking

Sentry is an open source error-tracking system that helps developers to monitor and track the error which are getting triggered in our code.

How Does sentry Work?

Sentry provides an SDK for many platforms, frameworks, and languages, and easy to integrate with our application and program stacks like python, node.js, and ruby. It will monitor application continuously and notify through the email or a phone call while we get an error in our code.

When should we use Sentry?

While our code was running in production mode if it throws error to end users, who will notify the developers?
How did the developer come to know about the urgency and impact of the bug?
How to set a root cause of the bug quickly?
After resolving the bug, how developer know the fixes are correct or not?

All these above questions can get an answer for our question.

Workflow of the sentry:

when the end-user hits the application’s server and unfortunately if it throws error to the users then sentry will immediately send a notification to the developer through either mail or slack or pager duty.
Those  specific notification will takes us to the sentry application dashboard. In the dashboard we can clearly show the bug report and where it is affected, the end users impact, and the details of end users. Also, from dashboard itself we can assign the bug to a particular developer in the team.
After identifying and resolving the issue, We can deploy the code to production, afterward no need to worry about the issue. Automatically sentry resolves the issue report aroused on dashboard once the code is deployed .  If the issue occurs again, the Sentry will mark it as regression and again it will be intimated to the developers.

Configuring Sentry with Rails Framework:

Process required to configure Sentry,

  • Sign Up the account with sentry

  • Configure an SDK With Ruby

  • DSN Configuration

 

Sign Up the account with sentry

Sign up and login to the sentry with required credentials,

Configure An SDK With Ruby

 

Installation:

If you’re using the builder, just add the gem in gemfile and lock with latest gem version. Raven Ruby SDK available as gem plugin.
Note: Raven for Ruby is a client and integration layer for the Sentry error reporting API. It supports Ruby 1.9.3 and above version.

gem “sentry-raven”

Alternatively, if you want to install the development version from GitHub, you can install with below command,

gem “sentry-raven”, :github => “getsentry/raven-ruby”

Another case, If we want to integrate sentry manually, we require “ravan/base” insteadof “ravan” or “sentry-raven”.
In gemfile give the below command,

gem “sentry-raven”, require:  false

Commands to initialize the code in our file,

require “raven/base”
 require “raven/integrations/rails”
 require “raven/integrations/delayed_job”

We’re almost done, Now, we need to configure the DSN with an application. We can find This SENTRY_DSN environment variable in project setting page under the API keys. 

After adding and defining items to the log filter then sentry will not sent those items.

Some Inbuilt Features Of Sentry

Async With Raven

If the errors are continuously triggering in code, then Raven will immediately send the notifications to the sentry whereas Sentry already has explicitly configured with Raven to send the notifications asynchronously.

Moreover, Raven will create a background job, using a background job processor that will send notifications in the background.

Encoding

Raven compresses outgoing messages with gzip by default.  If you want to disable the zip, need to config the below settings in the file named “application.rb”.

Environments

Sentry will process with all the environment live development, production and testing, Meanwhile if you want to process the particular environment then you can achieve it with the below mentioned way.

Excluded_exceptions

If you want to skip some exception, specify ‘excluded_exceptions’ in the configuration file.

Logger

Sentry uses the logger to address the bug reports. The default instance of Raven  Raven::Logger because Raven respects the logger status.

Notification

Typically, Sentry sends an error report notification to the specified email which is defaulty configured with sentry.

The End! Almost i have covered all the topics that could help to integrate Rails with Sentry. Luckily, This open source tool will seamlessly help us to track and fix the errors then & there by providing clear insights of error report.

For more Technical blogs, check out our largest blog repository  and for any inquiries reach us via info@agiratech.com

The following two tabs change content below.

Karthiga M

A desired and an ideal full stack developer having 2 years of experience in web development, Acquiring strong development skills in building Ruby On Rails and React Js applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

[contact-form-7 id="120788" title="Web Page Form"]

Schedule Your Call