Skip to content

Commit

Permalink
eval: use rate per step for sample messages (#1732)
Browse files Browse the repository at this point in the history
For the value associated with sampled events, use the rate
per step, i.e. raw count for that step interval, rather than
the rate per second. This is more intuitive for users.
  • Loading branch information
brharrington authored Dec 3, 2024
1 parent 5c8957f commit bab3e62
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ private[stream] class FinalExprEval(exprInterpreter: ExprInterpreter, enableNoDa
}

private def toTimeSeriesMessage(value: AggrDatapoint): TimeSeriesMessage = {
// For sampled messages, convert to rate per step, i.e. a raw count per step, rather
// than a rate per second.
val secondsPerStep = step / 1000.0
val ratePerStep = value.value * secondsPerStep
val id = TaggedItem.computeId(value.tags + ("atlas.query" -> value.source)).toString
TimeSeriesMessage(
id,
Expand All @@ -309,7 +313,7 @@ private[stream] class FinalExprEval(exprInterpreter: ExprInterpreter, enableNoDa
step,
TimeSeries.toLabel(value.tags),
value.tags,
ArrayData(Array(value.value)),
ArrayData(Array(ratePerStep)),
None,
value.samples
)
Expand Down

0 comments on commit bab3e62

Please sign in to comment.