#108 Tracking Errors with Sentry
12-3-2017

Summary

Sentry is an Open Source error tracking that helps developers monitor and fix crashes in real time. Learn how to add and configure Sentry to your application.
7
rails error 7:44

Summary

Gemfilegem 'sentry-raven'
config/initializers/sentry.rbRaven.configure do |config|
  config.dsn = 'https://7e4ed0cd459a4368bcf12f319bdde289:[email protected]/253803'
  config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
  config.release = APP_VERSION
end
application_controller.rbclass ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_action :set_raven_context

  private

  def set_raven_context
    Raven.user_context(id: session[:current_user_id], foo: :bar)
    Raven.extra_context(params: params.to_unsafe_h, url: request.url)
  end
end
config/application.rbrequire_relative 'boot'

require 'rails/all'
require_relative 'version'

...


there are turning to ah to add a turn around and let for them to the one who is about figuring he said freezer for what it did did and sentries at tracking software product which has many differences which options so the user has it been since the beginning of a free option with up to ten thousand events per month with one user or eating is what they're paid plenty of yet more users or if you need to retain cater for longer period of time or if you have more than ten thousand events within a mile clever the article covered setting up said trade within your own environment say he knows it yourself so in this episode where to look at setting up our wills application to use century i'm a big tennis entry because i tried to learn some things were on catching years within the rails application in opposing it to slack but it doesn't always catch all of the errors and there's some situations where would one to be notified is something and this error tracker just didn't pick up what role with sentry f l that even some errors within like a background jobs is psychic or other situations where you would not normally get notified of the inner city so picks us up and then since about the deathly beats parsing your logs said to get started will quickly get started on the top right of succeed on audio and they will just the latter information will create a email address and password and then agree to their terms and privacy policy we create a project them honor our application and in this case would it be using the bills application will ever did see that it supports many other languages and frame works so i'll click on rails and all just rename this project to after we beat us there will create the project what they have really like about century is that it actually gives you some documentation on how to set it up with the new application they would have followed the steps now so within our gym fall will add the gym sentry raven the mission rom bottle the letter we sorry wells application yeah because we're didn't create a cafe can visualize surfer century and so the next step is to copy this code and instead of putting in the cafe application daughter be a win a copy it over into a financial lies or fall saw that under the cafe initial lies years and then sentry better be a cell with american third initial lies ers inner city god or the file which is based in that code and there's another initial as a foreigner rails five application called the filter parameter logging the within this while he didn't see that we have the will say application configure filter parameters so reading into this camp that prouder password in the purpose of this is al whenever a post occurs within your application is sitting parameters from a forum or something back into your application and when you kill in the logs you can see all the parameters center had said that as well off he's gay or hide the password from being implied that's what the new locks the deathly is a needed security we wanna make sure they do is also prevent the password for the week in your log files or in your hair files better in century so with the inner city are b we had a additional line and messages goodness sake of fake sanitize fields that were referencing the premier filters from the premier fill the walking down or be that we may should then all of the attributes within there are strings and then sometimes when you look you know baltic it doesn't really help you to just have the error message because you might need to be able to go back to the actual use of else having the issue the tenor we create the problems the you know how to fix it and they offered the transit sessions where within your application people are you ready before action which will run a private method within this private method when reading the user context the hills as cd can add extra content that will see with this looks like we had these and then have an error on the application and gets posted century lever on like a good weekend authorization sword i actually didn't have a great user id or anything but will get the point so within our application controller daughter be file a great people for action that integrate the private method said rating contacts within here we every user contacts with the session and passing in the current user id that we can also pass in something else we could also doesn't edition primers like you and them bar and then now they're very helpful thing to do it said know what version is actually being affected by this area that gets reported this century so on the create a version that are being filed in there within he can take application better be on just require a relative path to this version final bill within the verse and file all had a major minor hi any event a pre version and these as gay come back again and joined with a period so this will follow these meant that for sending men have access to this global variable app version and they're within the sentry configuration we invent a new line then just call the cafe got really sick eagles the app version the delicatessen sell i created a scaffold called users within year we ever center court actions and we have our index in our show sober for score to get to work index and they were going to click the button to create a new user it said the users created e. create action will send us to the show page and on the show page are just going to put in the air so we're just going to call raise they should create an exception to escalate it doesn't sell so offers create a new user and august though the cell magnolia create name you see that we get our air because we had that raised within our show page you see that we got one error and this is affecting one user if we click on the us we can actually get some great details about this application so on the right hand side we can see where this occurred we can also see the release now because we added envy a fake version so it gives us the beloved they could with the error occurred we see information about the request them we can see some contact information about the user in in this case there is or fruit and then there is a valuable or they got past that they had this all been out of like the parameters that were passed this was some information about the server there's a lot more cool been seeking to honor the project settings but we did a project settings in there we go down to the all integration is you can see that there's many different programs they can integrate wet lot of times they suggest a huge integrated with your could we go so with the labyrinth yet have versa ping similar then you could also have it on to create a duet ticket so when sentry reports here even though you're free account has only seven days retention yeah they automatically create a jerk and get what the what the information so they needed us on the developer to the war going on in a plug in is like reading to figure this plug in baby disappointed to a blackhawk the ukraine on the slack side they even have a point to a certain destination and away the will of the people can follow that channel be notified when something happens all this offer this episode they keep watching