From 7f0618e6efa2116b0596c26a26ff88850e2d56c2 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 6 Dec 2024 10:29:36 +0100 Subject: [PATCH 1/2] refactor(log): always use Current.request_id --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index afaf48762..f540da41b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -256,7 +256,7 @@ class ApplicationController < ActionController::Base user_id: current_user&.id, user_roles: current_user_roles, client_ip: request.headers['X-Forwarded-For'], - request_id: request.headers['X-Request-ID'] + request_id: Current.request_id }) if browser.known? From 2b749b2c5b555d65bcd38430f4420e226a5ffa81 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 6 Dec 2024 11:09:01 +0100 Subject: [PATCH 2/2] feat: log timeout search terms --- app/controllers/recherche_controller.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/controllers/recherche_controller.rb b/app/controllers/recherche_controller.rb index 63772f839..33ce5c5a7 100644 --- a/app/controllers/recherche_controller.rb +++ b/app/controllers/recherche_controller.rb @@ -71,6 +71,23 @@ class RechercheController < ApplicationController else return end + + rescue ActiveRecord::QueryCanceled => e + Sentry.capture_exception(e) + + logger = Lograge.logger || Rails.logger + + payload = { + message: 'search timeout', + user_id: current_user.id, + request_id: Current.request_id, + controller: self.class.name, + terms: @search_terms + } + + logger.info(payload.to_json) + + redirect_to recherche_index_path, alert: "La recherche n'a pas pu aboutir." end private