Skip to content

Commit

Permalink
Adds profiling to Net::IMAP and Mail::SMTP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Kjeldahl committed Jul 4, 2016
1 parent bcf7380 commit 8a27391
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/patches/net_patches.rb
Expand Up @@ -12,3 +12,31 @@ def request_with_mini_profiler(*args, &block)
end

end

if (defined?(Net) && defined?(Net::IMAP))

Net::IMAP.class_eval do
def send_command_with_mini_profiler(cmd, *args, &block)
Rack::MiniProfiler.step("Net::IMAP #{cmd}") do
send_command_without_mini_profiler(cmd, *args, &block)
end
end
alias send_command_without_mini_profiler send_command
alias send_command send_command_with_mini_profiler
end

end

if (defined?(Mail) && defined?(Mail::SMTP))

Mail::SMTP.class_eval do
def deliver_with_mini_profiler(mail)
Rack::MiniProfiler.step("Mail::SMTP #{settings[:address]}:#{settings[:port]}") do
deliver_without_mini_profiler(mail)
end
end
alias deliver_without_mini_profiler deliver!
alias deliver! deliver_with_mini_profiler
end

end

0 comments on commit 8a27391

Please sign in to comment.