Metrics

Eric Wong normalperson at yhbt.net
Thu Oct 22 01:13:13 EDT 2009


John Wulff <johnwulff at gmail.com> wrote:
> I'm a Munin-aholic (http://github.com/jwulff/munin_plugins) and I'd
> like to write a plugin for Unicorn.  Does Unicorn keep any interesting
> metrics?  Requests handled, etc.?  If so, where can I find/access
> them?

Nope, Unicorn tries to avoid anything that can be better implemented as
a Rack handler.  You could probably start with something like this:

# this is totally untested of course :)
class RequestCounter < Struct.new(:app, :nr)

  def initialize(app)
    super(app, 0)
  end

  def call(env)
    if env["PATH_INFO"] == "/NR"
      [200, { "Content-Type" => "text/plain" }, [ "#{nr}\n" ] ]
    else
      self.nr += 1
      app.call(env)
    end
  end

end

-- 
Eric Wong


More information about the mongrel-unicorn mailing list