Browse Source

pop_active_record_summary

main
pvincent 3 months ago
parent
commit
0f04088ef9
  1. 18
      lib/semantic/subscribers/action_controller.rb

18
lib/semantic/subscribers/action_controller.rb

@ -56,7 +56,10 @@ module Semantic
status = ::ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
end
additions << pop_active_record_summary
additions << "GC: #{event.gc_time.round(1)}ms"
additions.compact!
if event.duration >= 1200
logger.error process_duration(event, additions)
elsif event.duration >= 600
@ -92,6 +95,21 @@ module Semantic
private
def pop_active_record_summary
active_record_transactions = Thread.current[ActiveRecord.to_s]
return unless active_record_transactions
# reset thread local
Thread.current[ActiveRecord.to_s] = nil
active_record_transactions.map do |k, art|
art.except(:total_duration)
.select { |_, value| value.positive? }
.map { |k, v| "#{v} #{k.to_s.pluralize(v)}" }
.join(',')
end.compact.join('|')
end
def redirect_regex
return @redirect_regex if defined?(@redirect_regex)

Loading…
Cancel
Save