Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

proper response format

  • Loading branch information...
commit 0fda05eaf91a223afaf6d30559e209faba05c536 1 parent 1031601
@paulasmuth authored
View
10 fnordmetric-doc/src/enterprise_tcp_udp_api.md
@@ -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
View
3  fnordmetric-enterprise/src/FnordMetric.scala
@@ -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
View
1  fnordmetric-enterprise/src/SwapFile.scala
@@ -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!
View
2  fnordmetric-enterprise/src/ValueAtInstruction.scala
@@ -16,7 +16,7 @@ class ValueAtInstruction(key: MetricKey, time: Long) extends AbstractInstruction
if (value == null)
"null"
else
- value.toString
+ FnordMetric.number_format.format(value)
}
}
View
14 fnordmetric-enterprise/src/ValuesInInstruction.scala
@@ -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
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.