-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Tracking #71
Comments
Integrating Sentry with Our ApplicationsBackend (Rails Application)1. Add Sentry Gems to Your GemfileAdd the # Gemfile
gem 'sentry-ruby'
gem 'sentry-rails' 2. Initialize Sentry in Rails ApplicationCreate an initializer # config/initializers/sentry.rb
Sentry.init do |config|
config.dsn = Config.sentry_dsn!
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
config.environment = Rails.env
config.release = Config.release_version
config.sanitize_fields = %w(password credit_card)
config.enabled_environments = %w(production staging)
end Replace Frontend (Typescript)1. Add Sentry Browser to Your ProjectRun the following command to add yarn add @sentry/browser 2. Initialize Sentry in Your TypescriptCreate a separate file or include this in your main Typescript file to initiate Sentry: // javascript/lib/error-tracking.ts
import * as Sentry from '@sentry/browser';
Sentry.init({
dsn: import.meta.env.SENTRY_DSN,
environment: import.meta.env.SENTRY_ENVIRONMENT || import.meta.env.RAILS_ENV,
}); Add
Replace Integrating the Rails Request ID1. Capture Request ID in the Controller# app/controllers/application_controller.rb
before_action :set_sentry_context
def set_sentry_context
Sentry.set_context("Request ID", { request_id: request.uuid })
end 2. Displaying Request ID on 500 Error PagesConfigure Rails to Show Custom Error Pages:Add the route at the top of the # config/routes.rb
match "/404", to: "errors#not_found", via: :all
match "/500", to: "errors#internal_server_error", via: :all Create an # app/controllers/errors_controller.rb
class ErrorsController < ApplicationController
skip_after_action :verify_authorized, only: [:not_found, :internal_server_error]
skip_before_action :assign_user, only: [:not_found, :internal_server_error]
skip_before_action :check_locale
before_action :assign_exception
before_action :capture_exception
def not_found
render status: :not_found
end
def internal_server_error
render status: :internal_server_error
end
private
def assign_exception
@exception = request.env["action_dispatch.exception"]
end
def capture_exception
Rails.error.report(@exception, handled: true)
end
end Display the Request ID on the Error Page<!-- app/views/errors/internal_server_error.html.slim -->
= request.uuid Responding to Errors in SentryStandard Operating Procedure (SOP)Follow these initial steps when an error is reported:
Documentation for Each Error
Team Communication and Coordination
|
@JensRavens, @danieldiekmeier, and @Adeynack I have created a simple guide based on anymator to add error tracking with sentry. Is there anything you would like to add above? Where should this documentation live? We could also consider to hook up projects/organization GitHub with sentry so it automatically creates issues for us so we don't have to do it manually. I don't have permissions on any project or the organization to see these settings though so @JensRavens or @ckroter would have to do it. https://docs.sentry.io/product/integrations/source-code-mgmt/github/ |
I think we don't have to add the Request ID to Sentry manually, Sentry seems to support this out of the box: getsentry/sentry-ruby#1120 |
I still cannot offer a clear answer to that. @JensRavens what's our stance there at the moment? What about a markdown file? Should it be here in |
The text was updated successfully, but these errors were encountered: