Class: RequireProfiler::Plugins::HTTPPlugin
- Defined in:
- lib/require_profiler/plugins/http_plugin.rb
Overview
Track HTTP calls using Sniffer and add the to the require profile
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #activate! ⇒ Object
-
#request(data_item) ⇒ Object
Sniffer hook interface.
- #response(data_item) ⇒ Object
Methods inherited from Base
Constructor Details
This class inherits a constructor from RequireProfiler::Plugins::Base
Instance Method Details
#activate! ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/require_profiler/plugins/http_plugin.rb', line 7 def activate! begin require "sniffer" rescue LoadError return end Sniffer.config.logger = Logger.new(IO::NULL) Sniffer.config.middleware do |chain| chain.add HTTPPlugin, reporter end Sniffer::DataItem::Request.include(Module.new do def require_path @url ||= "#{method.to_s.upcase}:#{(port == 443) ? "https" : "http"}://#{host}#{query}" end end) Sniffer.enable! end |