Commit 5fb3a300 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

stub VALUEAT and VALUESIN instructions

parent d003bd87
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ retrieves the value of a metric at one point in time

*Example:*

     >> VALUE_AT my_application.response_time.avg-30 -20min
     >> VALUE_AT my_application.response_time.avg-30 1382341536
     << 17.42


@@ -79,7 +79,7 @@ Retrieves all values of a metric in a time interval

*Example:*

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


+14 −1
Original line number Diff line number Diff line
@@ -9,7 +9,10 @@ package com.fnordmetric.enterprise

object InstructionFactory {

  val X_SAMPLE = """^SAMPLE (.*)(mean|sum)-([0-9]+) ([0-9]+\.?[0-9]*)$""".r
  val X_METRICKEY = """(.*)(mean|sum)-([0-9]+)"""
  val X_SAMPLE    = ("""^SAMPLE """ + X_METRICKEY + """ ([0-9]+\.?[0-9]*)$""").r
  val X_VALUESIN  = ("""^VALUES_?IN """ + X_METRICKEY + """ ([0-9]+) ([0-9]+)$""").r
  val X_VALUEAT   = ("""^VALUE_?AT """ + X_METRICKEY + """ ([0-9]+)$""").r

  def parse(str: String) : AbstractInstruction = str match {

@@ -18,6 +21,16 @@ object InstructionFactory {
        java.lang.Double.parseDouble(flush_interval).longValue * 1000),
        java.lang.Double.parseDouble(value))

    case X_VALUESIN(key, mode, flush_interval, time0, time1) =>
      new ValuesInInstruction(MetricKey(key, mode,
      java.lang.Double.parseDouble(flush_interval).longValue * 1000),
      java.lang.Long.parseLong(time0), java.lang.Long.parseLong(time1))

    case X_VALUEAT(key, mode, flush_interval, time) =>
      new ValueAtInstruction(MetricKey(key, mode,
      java.lang.Double.parseDouble(flush_interval).longValue * 1000),
      java.lang.Long.parseLong(time))

    case _ =>
      new ErrorInstruction("invalid command")

+17 −0
Original line number Diff line number Diff line
// FnordMetric Enterprise
//   (c) 2011-2013 Paul Asmuth <paul@paulasmuth.com>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT

package com.fnordmetric.enterprise

class ValueAtInstruction(key: MetricKey, time: Long) extends AbstractInstruction {

  def execute : String = {
    MetricFactory.get_metric(key)
    "OKFNORD"
  }

}
+17 −0
Original line number Diff line number Diff line
// FnordMetric Enterprise
//   (c) 2011-2013 Paul Asmuth <paul@paulasmuth.com>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT

package com.fnordmetric.enterprise

class ValuesInInstruction(key: MetricKey, time0: Long, time1: Long) extends AbstractInstruction {

  def execute : String = {
    MetricFactory.get_metric(key)
    "OKIDOKI"
  }

}