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
Sign Up the account with sentry
Sign up and login to the sentry with required credentials,
Configure An SDK With Ruby
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.
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,
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.
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”.
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.
If you want to skip some exception, specify ‘excluded_exceptions’ in the configuration file.
Sentry uses the logger to address the bug reports. The default instance of Raven Raven::Logger because Raven respects the logger status.
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.