Skip to content

Commit

Permalink
lwc-events: encode samples associated with datapoint (#1729)
Browse files Browse the repository at this point in the history
Update remote client to encode the samples and lwcapi to
read them.
  • Loading branch information
brharrington authored Nov 20, 2024
1 parent 80ed3f4 commit bee62c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ class RemoteLwcEventClient(registry: Registry, config: Config)
}
gen.writeEndObject()
gen.writeNumberField("value", event.value)
gen.writeFieldName("samples")
Json.encode(gen, event.samples)
gen.writeEndObject()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EvaluateApi(registry: Registry, sm: StreamSubscriptionManager)
req.metrics.groupBy(_.id).foreach {
case (id, ms) =>
val datapoints = ms.map { m =>
LwcDatapoint(timestamp, m.id, m.tags, m.value)
LwcDatapoint(timestamp, m.id, m.tags, m.value, m.samples)
}
evaluate(addr, id, datapoints)
}
Expand Down Expand Up @@ -87,7 +87,8 @@ object EvaluateApi {
case class Item(
id: String,
@JsonDeserialize(`using` = classOf[SortedTagMapDeserializer]) tags: SortedTagMap,
value: Double
value: Double,
samples: List[List[Any]]
)

case class EvaluateRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EvaluateApiSuite extends MUnitRouteSuite {
}

test("post metrics") {
val metrics = List(Item("abc", SortedTagMap("a" -> "1"), 42.0))
val metrics = List(Item("abc", SortedTagMap("a" -> "1"), 42.0, Nil))
val json = EvaluateRequest(1234L, metrics, Nil, Nil).toJson
Post("/lwc/api/v1/evaluate", json) ~> routes ~> check {
assertEquals(response.status, StatusCodes.OK)
Expand Down

0 comments on commit bee62c2

Please sign in to comment.