Commit 0fda05ea authored by Paul Asmuth's avatar Paul Asmuth
Browse files

proper response format

parent 10316015
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ retrieves the value of a metric at one point in time
     >> VALUE_AT my_application.response_time.avg-30 1382341536
     << 17.42

     >> VALUE_AT my_application.response_time.avg-30 1382341536
     << null


### Command: VALUES_IN

@@ -75,12 +78,15 @@ Retrieves all values of a metric in a time interval

*Response:*

    Comma-seperated Timestamp:Float tuples or "null"
    white space seperated Timestamp:Float tuples or "null"

*Example:*

     >> VALUE_AT my_application.response_time.avg-30 13823534644 13823414323
     << 1360804571:4233.52,1360804581:4312.36,1360804591:6323.12,
     << 1360804571:4233.52 1360804581:4312.36 1360804591:6323.12

     >> VALUE_AT my_application.response_time.avg-30 13823534644 13823414323
     << null


+3 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import java.io.File
import java.io.RandomAccessFile
import java.nio.channels.FileChannel
import java.nio.channels.FileLock
import java.text.DecimalFormat
import scala.collection.mutable.HashMap

object FnordMetric {
@@ -30,6 +31,8 @@ object FnordMetric {
    'swap_prefix -> "/tmp/fnordmetric"
  )

  val number_format = new DecimalFormat("0.#####")

  var debug = false
  var verbose = false

+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ class SwapFile(metric_key: MetricKey) {
    FnordMetric.CONFIG('swap_prefix), file_name), "rwd")

  var write_pos = file.length.toInt
  println(write_pos)

  // adds a new (time, value) tuple to be written to the swap file
  // but does not write it yet. this method is not thread safe!
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ class ValueAtInstruction(key: MetricKey, time: Long) extends AbstractInstruction
    if (value == null)
      "null"
    else
      value.toString
      FnordMetric.number_format.format(value)
  }

}
+13 −1
Original line number Diff line number Diff line
@@ -12,8 +12,20 @@ class ValuesInInstruction(key: MetricKey, time0: Long, time1: Long) extends Abst
  def execute : String = {
    val metric = MetricFactory.get_metric(key)
    val values = metric.values_in(time1 * 1000, time0 * 1000)
    val resp = new StringBuffer

    values.toString
    for (ind <- (0 until values.size)) {
      resp.append(values(ind)._1)
      resp.append(":")

      resp.append(FnordMetric.number_format.format((
        values(ind)._2)))

      if (ind < values.size - 1)
        resp.append(" ")
    }

    resp.toString
  }

}