From e974e26fcfb78cd579556495a0635d30ec5c6976 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 27 Sep 2011 17:46:20 -0700 Subject: watcher: add X-Current header to headers It can be useful to some to see that info all at once without hitting the HTML index page. --- lib/raindrops/watcher.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/raindrops/watcher.rb b/lib/raindrops/watcher.rb index 66bc7b6..f343e43 100644 --- a/lib/raindrops/watcher.rb +++ b/lib/raindrops/watcher.rb @@ -172,14 +172,16 @@ class Raindrops::Watcher def active_stats(addr) # :nodoc: @lock.synchronize do tmp = @active[addr] or return - [ @snapshot[0], @resets[addr], tmp.dup ] + time, combined = @snapshot + [ time, @resets[addr], tmp.dup, combined[addr].active ] end end def queued_stats(addr) # :nodoc: @lock.synchronize do tmp = @queued[addr] or return - [ @snapshot[0], @resets[addr], tmp.dup ] + time, combined = @snapshot + [ time, @resets[addr], tmp.dup, combined[addr].queued ] end end @@ -204,9 +206,10 @@ class Raindrops::Watcher end def histogram_txt(agg) - updated_at, reset_at, agg = *agg + updated_at, reset_at, agg, current = *agg headers = agg_to_hash(reset_at, agg) body = agg.to_s + headers["X-Current"] = current.to_s headers["Content-Type"] = "text/plain" headers["Expires"] = (updated_at + @delay).httpdate headers["Content-Length"] = bytesize(body).to_s @@ -214,7 +217,7 @@ class Raindrops::Watcher end def histogram_html(agg, addr) - updated_at, reset_at, agg = *agg + updated_at, reset_at, agg, current = *agg headers = agg_to_hash(reset_at, agg) body = "" \ "#{hostname} - #{escape_html addr}" \ @@ -225,6 +228,7 @@ class Raindrops::Watcher "
" \ "
" \ "" + headers["X-Current"] = current.to_s headers["Content-Type"] = "text/html" headers["Expires"] = (updated_at + @delay).httpdate headers["Content-Length"] = bytesize(body).to_s -- cgit v1.2.3-24-ge0c7