Commit 66a55c3c authored by Paul Asmuth's avatar Paul Asmuth
Browse files

Merge branch 'master' of github.com:paulasmuth/fnordmetric

parents cd052a27 e680c50d
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -363,12 +363,24 @@ FnordMetric.namespace :ulikeme do

  gauge :events_per_minute, :tick => 60
  gauge :events_per_hour, :tick => 1.hour.to_i
  gauge :events_per_second, :tick => 1
  gauge :votes_per_second, :tick => 1
  
  event :"*" do
    incr :events_per_minute
    incr :events_per_hour
    incr :events_per_second
  end


  event(:skip_vote){ incr :votes_per_second }
  event(:action_skip){ incr :votes_per_second }
  event(:yes_vote){ incr :votes_per_second }
  event(:action_yes){ incr :votes_per_second }
  event(:maybe_vote){ incr :votes_per_second }
  event(:action_maybe){ incr :votes_per_second }


  widget 'TechStats', {
    :title => "Events per Minute",
    :type => :timeline,
@@ -388,6 +400,27 @@ FnordMetric.namespace :ulikeme do
  }


  widget 'TechStats', {
    :title => "Events/Second",
    :type => :timeline,
    :width => 50,
    :gauges => :events_per_second,
    :include_current => true,
    :plot_style => :areaspline,
    :autoupdate => 1
  }


  widget 'TechStats', {
    :title => "Votes/Second",
    :type => :timeline,
    :width => 50,
    :gauges => :votes_per_second,
    :include_current => true,
    :plot_style => :areaspline,
    :autoupdate => 1
  }

end

#task :setup do
+3 −1
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@ class FnordMetric::TimelineWidget < FnordMetric::Widget
      :gauge_titles => gauge_titles,
      :start_timestamp => ticks.first,
      :end_timestamp => ticks.last,
      :autoupdate => (@opts[:autoupdate] || 0),
      :autoupdate => (@opts[:autoupdate] || 60),
      :include_current => !!@opts[:include_current],
      :plot_style => (@opts[:plot_style] || 'line'),
      :tick => tick
    )
  end
+28 −9
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ var FnordMetric = (function(){
      for(k in opts.gauges){
        var gtick = parseInt(opts.gauges[k].tick);        
        var gtitle = opts.gauges[k].title;
        //console.log(gtick);

        var container = $('<div></div>')
          .addClass('numbers_container')
          .addClass('size_'+opts.offsets.length)
@@ -296,7 +296,8 @@ var FnordMetric = (function(){
        if(!silent){ $(opts.elem).css('opacity', 0.5); }
        redrawDatepicker();    
        var _query = '?at='+opts.start_timestamp+'-'+opts.end_timestamp;    
        chart.series = [];
        //chart.series = [];
        max_y=0;
        //metrics_completed = 0;
        $(opts.gauges).each(function(i,gauge){
          $.ajax({
@@ -316,11 +317,8 @@ var FnordMetric = (function(){
            max_y = Math.max(max_y, raw_data[p]);
          }
  
          chart.yAxis[0].setExtremes(0,max_y);

          if(!first_time){ 
            chart.get('series-'+gauge).setData(series_data);            
            chart.redraw();
          } else {
            chart.addSeries({
              name: opts.gauge_titles[gauge], 
@@ -329,6 +327,9 @@ var FnordMetric = (function(){
            });     
          }       

          chart.yAxis[0].setExtremes(0,max_y);
          chart.redraw();

          // shown on the *first* gauge load
          $(opts.elem).css('opacity', 1);
        });
@@ -366,12 +367,22 @@ var FnordMetric = (function(){
          )
        ).append(
          $('<h2></h2>').html(opts.title)
        ) ).append( $('<div></div>').attr('id', 'container-'+widget_uid) );
        ) ).append( 
          $('<div></div>').attr('id', 'container-'+widget_uid).css({
            height: 256,
            marginBottom: 20,
            overflow: 'hidden'
          })
        );
      }

      function drawChart(){
        chart = new Highcharts.Chart({     
          chart: { renderTo: 'container-'+widget_uid, defaultSeriesType: 'line', height: 270 },
          chart: { 
            renderTo: 'container-'+widget_uid, 
            defaultSeriesType: opts.plot_style, 
            height: 270 
          },
          series: [],
          title: { text: '' },
          xAxis: {       
@@ -413,6 +424,14 @@ var FnordMetric = (function(){
        if(secs > 0){

          var autoupdate_interval = window.setInterval(function(){
            if(
              (parseInt(new Date().getTime()/1000) - opts.end_timestamp) >
              (opts.include_current ? 0 : opts.tick)
            ){
              opts.end_timestamp += opts.tick;
              opts.start_timestamp += opts.tick;
            }

            redrawWithRange(false, true);
          }, secs*1000);

+71 −44
Original line number Diff line number Diff line
@@ -49,24 +49,17 @@ This is the easiest way to submit an event:
  echo "{'_type': 'unicorn_seen'}\n" | nc localhost 1337


== Documentation
== Installation

=== Example Events
here be dragons

  // track a pageview
  { "_type": "_pageview", "url": "/blob/my_super_seo_article", "_session": "mysessiontoken" }

  // track a waypoint (see below)
  { "_type": "_waypoint", "waypoint": "thank_you_site", "map": "checkout_flow", "_session": "mysessiontoken" }
== Configuration

  // track a custom action
  { "_type": "my_foo_type", "my_foo_action": "wink", "other_user": "myuserid" }
here be dragons

  // set the user name
  { "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }

  // set the user picture
  { "_type": "_set_picture", "url": "http://myhost/123.jpg", "_session": "mysessiontoken" }
== Documentation


=== Sending Events
@@ -90,7 +83,21 @@ The fast way: Add your event directly to the redis-based queue:
  redis.set("fnordmetric-event-#{my_uuid}", event)
  redis.expire("fnordmetric-event-#{my_uuid}", 60)

---

=== Special Events

  // track a pageview
  { "_type": "_pageview", "url": "/blob/my_super_seo_article", "_session": "mysessiontoken" }

  // set the user name
  { "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }

  // set the user picture
  { "_type": "_set_picture", "url": "http://myhost/123.jpg", "_session": "mysessiontoken" }


---

=== DSL Methods

@@ -100,7 +107,10 @@ The fast way: Add your event directly to the redis-based queue:

  event

=== Handler Methods

---

=== Event Handlers

call these methods from the event-handler block

@@ -116,24 +126,36 @@ call these methods from the event-handler block
  set_field(gauge_name, field_name, value)
    Set the given  field on a three-dimensional gauge to value at the tick specified by event-time (overwrite existing value)

e.g.

  event :user_signed_up do
    incr(:total_registrations, 1)
    incr_field(:users_per_gender, data[:gender], 1)
  end
---

=== Gauges

---

=== Widgets

==== Widget-Options: TimelineWidget

[plot_style] one of: line, areaspline
[include_current] show the current tick?
[autoupdate] auto-refresh the timeline every n secs (0 turns autoupdate off)

==== Widget-Options: Numbers-Widget

==== Widget-Options: ToplistWidget

  # example event:
  # { "_type": "user_signed_up", "gender": "male" }

---

=== Gauge Options
=== JSON API

=== Widget-Options: TimelineWidget

=== Widget-Options: Numbers-Widget

=== Widget-Options: ToplistWidget
== Examples
  
(link1), (link2), (link3), (link4)



== Full Example
@@ -270,19 +292,24 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  -> set_value / set_field
  -> bars-widget
  -> combine/calculation gauges via opts_gauge({}, &block) (+calculate ctr)
  -> timeline_widget: 'compare mode': compate gauge to yesterday
  -> fix include_current
  -> numbers_widget: handle decreasing vals
-> numbers_widget: list style
-> subscribe to metrics via websocket :)
  -> make redis-addr and redis-prefix + listen-ports configurable
  -> referal tracking fu (parse googlequeries)  
  -> trend detection
  -> funnel-widget, pie-widget
-> referall tracking fu (parse googlequeries)
-> timelinewidget + numberswidget => should use redis hmget
-> get multiple metrics in a single http get
  -> opt_event options: :increment => gauge_name
  -> preconfigured default-dashboard (like google analytics)
  -> pagview+ref-tracking via js-tracking-pixel 
  -> table/gauge-list-widget (with mini-stats!)
  -> prune the namespace-sessions-timline (remove event_ids older than x)
  -> prune the namespace-event-types-list (trim to max items)
-> opt_event options: :increment => gauge_name
-> custom calculation blocks: calculate ctr
  -> timelinewidget + numberswidget => should use redis hmget
  -> get multiple metrics in a single http get
  -> { _namespace: myns } field (!!!)
  

  -> demo / example: chatroom;  
    -> events: msg_read, msg_sent, {reg_start, reg_register, reg_active}, login (+demog.data+lang), referall