Skip to content
Extraits de code Groupes Projets
Valider bb58544a rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Add logging for GC (slight slowdown, but worth it for the data)

parent 0b6375ae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base ...@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
before_filter :set_invites before_filter :set_invites
before_filter :set_locale before_filter :set_locale
before_filter :which_action_and_user before_filter :which_action_and_user
prepend_before_filter :clear_gc_stats
def set_contacts_notifications_and_status def set_contacts_notifications_and_status
if user_signed_in? if user_signed_in?
...@@ -50,4 +51,7 @@ class ApplicationController < ActionController::Base ...@@ -50,4 +51,7 @@ class ApplicationController < ActionController::Base
I18n.locale = request.compatible_language_from AVAILABLE_LANGUAGE_CODES I18n.locale = request.compatible_language_from AVAILABLE_LANGUAGE_CODES
end end
end end
def clear_gc_stats
GC.clear_stats if GC.respond_to?(:clear_stats)
end
end end
...@@ -51,3 +51,4 @@ end ...@@ -51,3 +51,4 @@ end
# Sacrifice readability for a 10% performance boost # Sacrifice readability for a 10% performance boost
Haml::Template::options[:ugly] = true Haml::Template::options[:ugly] = true
GC.enable_stats if GC.respond_to?(:enable_stats)
...@@ -19,6 +19,7 @@ module ActionDispatch ...@@ -19,6 +19,7 @@ module ActionDispatch
ActiveSupport::Deprecation.silence do ActiveSupport::Deprecation.silence do
message = "event=error error_class=#{exception.class} error_message='#{exception.message}' " message = "event=error error_class=#{exception.class} error_message='#{exception.message}' "
message << "gc_ms=#{GC.time} gc_collections=#{GC.collections} gc_bytes=#{GC.growth} " if GC.respond_to?(:enable_stats)
message << "orig_error_message='#{exception.original_exception.message}'" if exception.respond_to?(:original_exception) message << "orig_error_message='#{exception.original_exception.message}'" if exception.respond_to?(:original_exception)
message << "annotated_source='#{exception.annoted_source_code.to_s}' " if exception.respond_to?(:annoted_source_code) message << "annotated_source='#{exception.annoted_source_code.to_s}' " if exception.respond_to?(:annoted_source_code)
message << "app_backtrace='#{application_trace(exception).join(";")}'" message << "app_backtrace='#{application_trace(exception).join(";")}'"
...@@ -41,6 +42,7 @@ class ActionController::LogSubscriber ...@@ -41,6 +42,7 @@ class ActionController::LogSubscriber
log_string = "event=request_completed status=#{payload[:status]} " log_string = "event=request_completed status=#{payload[:status]} "
log_string << "controller=#{payload[:controller]} action=#{payload[:action]} format=#{payload[:formats].first.to_s.upcase} " log_string << "controller=#{payload[:controller]} action=#{payload[:action]} format=#{payload[:formats].first.to_s.upcase} "
log_string << "ms=#{"%.0f" % event.duration} " log_string << "ms=#{"%.0f" % event.duration} "
log_string << "gc_ms=#{GC.time} gc_collections=#{GC.collections} gc_bytes=#{GC.growth} " if GC.respond_to?(:enable_stats)
log_string << "params='#{params.inspect}' " unless params.empty? log_string << "params='#{params.inspect}' " unless params.empty?
#log_string << "additions='#{additions.join(" | ")}' " unless additions.blank? #log_string << "additions='#{additions.join(" | ")}' " unless additions.blank?
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter