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

metric stubs

parent 119f5166
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -9,12 +9,20 @@ package com.fnordmetric.enterprise

case class MetricKey(key: String, mode: String, flush_interval: Long)

class Metric {
class Metric(key: MetricKey) {
  val bucket = BucketFactory.new_bucket(key.mode)
  var rbuf = new RingBuffer[Double](10)

  def sample(value: Double) = this.synchronized {
  /*flush...
    sample(value)*/
    println("........", value)
    bucket.flush_every(key.flush_interval, (
      (time, value) => flush(time, value) ))

    bucket.sample(value)
  }

  def flush(time: Long, value: Double) = this.synchronized {
    rbuf.push(value)
    println("RINGBUF", rbuf.tail(10))
  }

}
+1 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ object MetricFactory {
        metric = metric_map.getOrElse(key, null)

        if (metric == null) {
          metric = new_metric(key)
          metric = new Metric(key)
          metric_map += ((key, metric))
        }
      }
@@ -31,8 +31,4 @@ object MetricFactory {
    metric
  }

  def new_metric(key: MetricKey) : Metric = {
    new Metric
  }

}