Class: NewRelic::Rack::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/new_relic/rack/metric_app.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/new_relic/rack/metric_app.rb', line 33

def call(env)
  request = ::Rack::Request.new env
  data_url = "http://#{env['HTTP_HOST']}/metrics/path?value=nnn"
  body = StringIO.new
  body.puts "<html><body>"
  body.puts "<h1>New Relic Actively Monitoring #{NewRelic::Control.instance.app_names.join(' and ')}</h1>"
  body.puts "<p>To submit a metric value, use <a href='#{data_url}'>#{data_url}</a></p>"
  body.puts "<h2>Request Details</h2>"
  body.puts "<dl>"
  body.puts "<dt>ip<dd>#{request.ip}"
  body.puts "<dt>host<dd>#{request.host}"
  body.puts "<dt>path<dd>#{request.url}"
  body.puts "<dt>query<dd>#{request.query_string}"
  body.puts "<dt>params<dd>#{request.params.inspect}"
  body.puts "</dl>"
  body.puts "<h2>Complete ENV</h2>"
  body.puts "<ul>"
  body.puts env.to_a.map{|k,v| "<li>#{k} = #{v}</li>" }.join("\n")
  body.puts "</ul></body></html>"
  response = ::Rack::Response.new body.string
  response.finish
end