Class: Rack::Logstash
- Inherits:
-
Object
- Object
- Rack::Logstash
- Defined in:
- lib/rack/logstash.rb,
lib/rack/logstash/transport.rb
Defined Under Namespace
Classes: Transport
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, url, opts = {}) ⇒ Logstash
constructor
A new instance of Logstash.
Constructor Details
#initialize(app, url, opts = {}) ⇒ Logstash
Returns a new instance of Logstash.
9 10 11 12 13 |
# File 'lib/rack/logstash.rb', line 9 def initialize(app, url, opts = {}) @app = app @server = Rack::Logstash::Transport.new(url) = opts.fetch(:tags, []) end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rack/logstash.rb', line 15 def call(env) env['rack.logstash.start_time'] = Time.now begin @app.call(env).tap do |response| begin log_request(env, response) rescue StandardError => ex $stderr.puts "Failed to log request: #{ex.message} (#{ex.class})" $stderr.puts ex.backtrace.map { |l| " #{l}" } end end rescue StandardError => ex log_exception(env, ex) raise end end |