Skip to content

Commit

Permalink
Exporter now accepts floating-point data point values.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreifecioru committed Jan 30, 2020
1 parent 99af3a0 commit a0d08c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions web/app/models/OpenTsdbQueryResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import play.api.libs.functional.syntax._

case class DataPoint(
timestamp: Long,
value: Long
value: Double
)

case class PrometheusMetric(
name: String,
description: String,
metricType: String,
tags: Map[String, String],
value: Long
value: Double
) {
// def asOutputString: String = {
// val tagsAsString = tags.map(s"$k=$v")
Expand Down Expand Up @@ -87,10 +87,10 @@ object TsdbQueryResult {
implicit val tsdbQueryResultReads: Reads[TsdbQueryResult] = (
(JsPath \ "metric").read[String] and
(JsPath \ "tags").read[Map[String, String]] and
(JsPath \ "dps").read[Map[String, Long]] and
(JsPath \ "dps").read[Map[String, Double]] and
(JsPath \ "query").read[SubQuery]
)(
(metric: String, tags: Map[String, String], dps: Map[String, Long], query: SubQuery) =>
(metric: String, tags: Map[String, String], dps: Map[String, Double], query: SubQuery) =>
TsdbQueryResult(
metric = metric,
tags = tags,
Expand Down
6 changes: 3 additions & 3 deletions web/test/MetricsControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class MetricsControllerSpec extends PlaySpec
output must contain theSameElementsInOrderAs List(
"# HELP test_app_metrics_one TestApp metrics: one",
"# TYPE test_app_metrics_one counter",
"""test_app_metrics_one{severity="critical",escalation="pagerduty",role="developer"} 15""",
"""test_app_metrics_one{severity="critical",escalation="pagerduty",role="developer"} 15.0""",
"# HELP test_app_metrics_two TestApp metrics: two",
"# TYPE test_app_metrics_two counter",
"""test_app_metrics_two{severity="critical",escalation="pagerduty",role="developer"} 10"""
"""test_app_metrics_two{severity="critical",escalation="pagerduty",role="developer"} 10.0"""
)
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ class SimpleOpenTsdbWSMock extends OpenTsdbWSMock {
| "1496131204": 15,
| "1496131205": 15,
| "1496131206": 15,
| "1496131207": 15,
| "1496131207": 15.5,
| "1496131208": 15,
| "1496131209": 15,
| "1496131211": 15,
Expand Down
2 changes: 1 addition & 1 deletion web/test/tools/OpenTsdbWSMock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ abstract class OpenTsdbWSMock extends Mockito with WSClient {

protected def responsePayload: Map[String, JsValue]

override def close() = ()
override def close(): Unit = ()
}

0 comments on commit a0d08c2

Please sign in to comment.