Commit db190344 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

toplist gauge view

parent d06cde43
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -6,8 +6,11 @@ BACKLOG
-------

- gauge-view: interval selection dropdown 
- interval selection top like gh.com/graphs/commit-activity) 52w history
- fix pie widget
- use rack websocket instead of em websocket
- store per-session-data
- callback on session-flush
- split up fnordmetric.namespace block into multiple files
- fix hash-history fu


@@ -16,13 +19,9 @@ BACKLOG
-------

  > Core: Backend
    - split up fnordmetric.namespace block into multiple files
    - special events (incr, observe etc)
    - caching
    - use rack websocket instead of em websocket
    - gauge garbage-collection
    - store per-session-data
    - callback on session-flush
    - fix specs
    - new full_example.rb

+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ require "fnordmetric/gauges/eventfeed_gauge"
require "fnordmetric/context"
require "fnordmetric/histogram"
require "fnordmetric/timeseries"
require "fnordmetric/toplist"
require "fnordmetric/namespace"
require "fnordmetric/session"
require "fnordmetric/api"
+4 −10
Original line number Diff line number Diff line
@@ -2,17 +2,13 @@ class FnordMetric::ToplistGauge < FnordMetric::Gauge

  def render(namespace, event)
    interval = parse_interval(event["interval"])

    #@toplist = FnordMetric::Toplist.new
    @toplist = FnordMetric::Toplist.new

    ticks_in(interval).each do |_tick|
      puts field_values_at(_tick, 
        :limit => top_k, 
        :append => :toplist
      ).inspect
      field_values_at(_tick, :limit => top_k, :append => :toplist).each do |item, count|
        @toplist.incr_item(_tick, item, count)
      end
    end    

    @toplist = {}

    render_page(:toplist_gauge)
  end
@@ -29,8 +25,6 @@ class FnordMetric::ToplistGauge < FnordMetric::Gauge
private

  def observe(ctx, item)
    puts "YAY"

    at = ctx.send(:time)
    ctx.redis_exec :zincrby, tick_key(at, :toplist), 1, item
    ctx.redis_exec :incrby, tick_key(at, :total), 1
+20 −0
Original line number Diff line number Diff line
class FnordMetric::Toplist

  attr_accessor :toplist, :timelines, :total

  def initialize(timeline = {})
    @total   = 0
    @toplist = Hash.new{ |h,k| h[k] = 0 }

    @timelines = Hash.new do |h,k|
      h[k] = Hash.new{ |h,k| h[k] = 0 }
    end    
  end

  def incr_item(time, item, value)
    @toplist[item] += value.to_f
    @timelines[item][time] += value.to_f
    @total += value.to_f
  end

end
 No newline at end of file
+57 −0
Original line number Diff line number Diff line
@@ -40,6 +40,59 @@ a.link:hover{
  text-decoration:underline;
}

button,
input,
select,
textarea {
  margin: 0;
  font-size: 100%;
  vertical-align: middle;
}

button,
input {
  *overflow: visible;
  line-height: normal;
}

button::-moz-focus-inner,
input::-moz-focus-inner {
  padding: 0;
  border: 0;
}

button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  cursor: pointer;
  -webkit-appearance: button;
}

input[type="search"] {
  -webkit-box-sizing: content-box;
     -moz-box-sizing: content-box;
          box-sizing: content-box;
  -webkit-appearance: textfield;
}

input[type="search"]::-webkit-search-decoration{
  -webkit-appearance: none;
}

input[type="search"], input[type="text"]{
  border:1px solid #cecece;
  background:#fff;
  border-radius:3px;
  height: 28px;
  line-height: 28px;
  padding: 0 8px;
  color: #333;
  font-size: 14px;
  box-shadow: 0 0 2px 1px rgba(0,0,0,0.1) inset;
}


.shown{ display: block; }
.hidden{ display: none; }

@@ -172,6 +225,10 @@ color:#000;
.ui_toplist .toplist_item .value{ float:right; line-height:42px; margin-right:20px; font-size:13px; font-weight:bold; color:#333; width:70px; color:#666; }
.ui_toplist .toplist_item .percent{ float:right; line-height:42px; margin-right:20px; font-size:18px; font-weight:bold; color:#333; width:70px; }

.ui_toplist .searchbar{ background: #EFEFEF; border-bottom: 1px solid #DDD; padding:10px 17px; }



.headbar {

  height:36px;
Loading