LogoDTreeLabs

Specterr – An Error Reporting tool Which takes care of your data privacy

Kapil BhosaleBy Kapil Bhosale in RubyActiveSupport on May 21, 2019

Recently i.e. on 10th of August 2019, I gave a talk in a Regional Ruby Conference here in Pune (Deccan Ruby Conf). In this blog, I will try to cover the details of the talk.

We created a gem named specterr that stands for Spectacles on Error. Purpose of this gem is to create an error tracking tool which stores the tracked data in the same eco-system as that of your app. Most of the other gems will track the errors but the data is stored on tools cloud. This type of behavior is not allowed as per some regulations such as GDPR.

Let’s get into the details of the gem specterr. This gem is divided into two parts.

  • Error collection mechanism
  • In-app mounted UI to show the errors.

Let me explain in detail about the Error collection Mechanism that can be used ruby/Rails projects.

Rails provides a very powerful tool named ActiveSupport instrumentation, with the help of which we can choose to get notified when certain events occur inside the Rails app. There are multiple such hooks to which other developers and hook into.

The particular hook that is subscribed to collect exceptions is process_action.action_controller. Whenever the controller action execution is completed Rails will inform via this hook to the listener/subscriber.

How to subscribe to ActiveSupport instrumentation hooks?

You need to have an initializer that subscribed to the particular Rails hook.

In this example, I have created a file named exception_listener.rb inside the config/initializer directory with the following code.

config/initializers/exception_listener.rb

subscriber You can find the slides here.