From cd6b7459a7ff219364551ea0e446e58fbce9704f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 23 Feb 2022 12:45:42 +0000 Subject: [PATCH] DEV: Improve background-request information in request_tracker (#16037) This will allow consumers (e.g. the discourse-prometheus plugin) to separate topic-timings and message-bus requests. It also fixes the is_background boolean for subfolder sites. --- lib/middleware/request_tracker.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/middleware/request_tracker.rb b/lib/middleware/request_tracker.rb index fa035a00879..502b78daf6a 100644 --- a/lib/middleware/request_tracker.rb +++ b/lib/middleware/request_tracker.rb @@ -110,11 +110,15 @@ class Middleware::RequestTracker has_auth_cookie = Auth::DefaultCurrentUserProvider.find_v0_auth_cookie(request).present? has_auth_cookie ||= Auth::DefaultCurrentUserProvider.find_v1_auth_cookie(env).present? + is_message_bus = request.path.start_with?("#{Discourse.base_path}/message-bus/") + is_topic_timings = request.path.start_with?("#{Discourse.base_path}/topics/timings") + h = { status: status, is_crawler: helper.is_crawler?, has_auth_cookie: has_auth_cookie, - is_background: !!(request.path =~ /^\/message-bus\// || request.path =~ /\/topics\/timings/), + is_background: is_message_bus || is_topic_timings, + background_type: is_message_bus ? "message-bus" : "topic-timings", is_mobile: helper.is_mobile?, track_view: track_view, timing: timing,