Commit 6f4ceb6c authored by Paul Asmuth's avatar Paul Asmuth
Browse files

Metric#value_at, Metric#values_in stubs

parent 866b5b3a
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ class Metric(key: MetricKey) {
  var rbuf = new RingBuffer[(Long, Double)](1000)
  var rbuf_seek_pos = 0

  // adds a value to this metric
  // adds a value to the metric's bucket and tries to flush the bucket
  def sample(value: Double) = this.synchronized {

    bucket.flush_every(key.flush_interval, (
@@ -24,8 +24,8 @@ class Metric(key: MetricKey) {
    bucket.sample(value)
  }

  // adds an aggregated value to the in memory ring buffer after it has been
  // flushed from the bucket
  // adds an aggregated value to the in memory ring buffer after it has
  // been flushed from the bucket
  private def flush_bucket(time: Long, value: Double) = {
    if (rbuf.remaining == 0) {

@@ -56,4 +56,26 @@ class Metric(key: MetricKey) {
    rbuf_seek_pos += flush_range
  }


  // returns this metrics value at time0 if a value was recorded at that
  // point in time
  def value_at(time0: Long) : Option[Double] = {
    val values = values_in(time0, 0)

    if (values.size > 0)
      Some(values.first._2)
    else
      None
  }

  // returns all aggregated values for this metric in the specified time
  // range. if time1 is 0 then only the first value at time0 is returned
  def values_in(time0: Long, time1: Long) : List[(Long, Double)] = {
    val lst = List[(Long, Double)]()

    // here be dragons

    lst
  }

}