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

allow the user to explicitly define the histogram windows

parent c553c203
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ BACKLOG
-------

- gauge-view: interval selection dropdown 
- histogram longtail cap
- async report generation / cache heatup
- report: print number of samples, interval-size on topright via scalaexp-buttonstyle
- caching
+6 −0
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ class FnordMetric::DistributionGauge < FnordMetric::Gauge
      end
    end

    if @opts[:value_ranges]
      @histogram_mode = @opts[:value_ranges]
    else
      @histogram_mode = [23, @histogram.max || 1].min
    end

    @mmm_timeseries_arr = @mmm_timeseries.to_a
      .map{ |k,v| [k, Hash[v.map{ |vk, vv| [vk, (vv.is_a?(Numeric) || vv.is_a?(Array)) ? vv : 0 ] }]] }
      .sort{ |a,b| a.first.to_i <=> b.first.to_i}
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ class FnordMetric::Histogram < Hash
  end

  def histogram(windows)
    Hash[histogram_windows(windows).map{ |w| [w,0] }].tap do |histo|
    windows = histogram_windows(windows) unless windows.is_a?(Array)
    Hash[windows.map{ |w| [w,0] }].tap do |histo|
      self.each do |k,v|
        histo.detect do |win, wval|          
          histo[win] += v if win.include?(k)
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@
    elem: $('.widget_histogram_bars'),
    height: 320,
    no_headbar: true,
    values: #{@histogram.json_histogram([23, @histogram.max || 1].min)}
    values: #{@histogram.json_histogram(@histogram_mode)}
  });