开发者

Displaying Rails response time in view

I'm trying to set up custom Pingdom monitoring of my Rails application and would like to craft an XML response that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<pingdom_http_custom_check>
  <status>OK</status>
  <response_time>210.22</response_time>
</pingdom_http_custom_check>

Where the response_time value is the time taken for Rails to render the XML response.

I've found some resources for doing this with Mongrel but I'm using Apache Passenger.

I have a solution implemented as a Sinatra-Metal endpoint like this:

class Pingdom 开发者_如何学Python< Sinatra::Base  
  set :views, "#{RAILS_ROOT}/app/views/metal"
  get '/pingdom' do
    @start_time = Time.now
    builder :pingdom
  end
end

and then I have a builder view:

xml.instruct!
xml.pingdom_http_custom_check do |pingdom_http_custom_check|
  pingdom_http_custom_check.status("OK")
  pingdom_http_custom_check.response_time((Time.now-@start_time)*1000)
end

(Note the response_time is in milliseconds).

This implementation is sufficient for checking that the application is up but the very fact that it is a metal endpoint means that it's not actually hitting the main Rails application and so isn't really a very good measure of the current response time of my application.

Does anyone have any good suggestions for a better approach?

Cheers, Arfon


What does the response time indicate? Have you considered using something like scout or new relic instead?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜