/** * Evaluate expressions for all subscriptions associated with the specified group using * the provided data. * * @param group * Name of the group. At Netflix this is typically the cluster that includes * the instance reporting data. * @param timestamp * Timestamp to use for the payload response. * @param vs * Set of values received for the group for the current time period. * @return * Payload that can be encoded and sent to Atlas streaming evaluation cluster. */ public EvalPayload eval(String group, long timestamp, List<TagsValuePair> vs) { List<Subscription> subs = subscriptions.getOrDefault(group, Collections.emptyList()); List<EvalPayload.Metric> metrics = new ArrayList<>(); for (Subscription s : subs) { DataExpr expr = s.dataExpr(); for (TagsValuePair pair : expr.eval(vs)) { EvalPayload.Metric m = new EvalPayload.Metric(s.getId(), pair.tags(), pair.value()); metrics.add(m); } } return new EvalPayload(timestamp, metrics); } }
@Test public void dataExpr() { Subscription sub = new Subscription().withExpression(":true,:sum"); Assertions.assertEquals(new DataExpr.Sum(Query.TRUE), sub.dataExpr()); }