Sha256: e42afbc3e742d8767837520dbd8492d23d1db9b6c7bd0e4d45f35de25d4506e0
Contents?: true
Size: 810 Bytes
Versions: 5
Compression:
Stored size: 810 Bytes
Contents
require 'ganymed/sampler/datasource' module Ganymed class Sampler ## # A Derive {DataSource data source} will store the derivative of the line # going from the last to the current value of the data source. Derive is # similar to a {Counter} {DataSource data source} in that it produces a # rate/s gauge, but only accepts absolute values and produces the # derivative instead of summation of all samples. # class Derive < DataSource def flush each do |ns, origin, ts| values = ts.each_cons(2).map do |a, b| (b[1].last - a[1].last)/(b[0] - a[0]) # ∆value / ∆ts end.reject do |value| value < 0 # ignore overflow/counter wrap end yield ns, origin, values end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems