Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/707#discussion_r134758686
--- Diff:
metron-analytics/metron-profiler-common/src/main/java/org/apache/metron/profiler/DefaultProfileBuilder.java
---
@@ -140,33 +144,41 @@ public void apply(JSONObject message) {
* @return Returns the completed profile measurement.
*/
@Override
- public ProfileMeasurement flush() {
+ public Optional<ProfileMeasurement> flush() {
LOG.debug("Flushing profile: profile={}, entity={}", profileName,
entity);
+ Optional<ProfileMeasurement> result = Optional.empty();
- // execute the 'profile' expression(s)
- @SuppressWarnings("unchecked")
- Object profileValue =
execute(definition.getResult().getProfileExpressions().getExpression(),
"result/profile");
-
- // execute the 'triage' expression(s)
- Map<String, Object> triageValues =
definition.getResult().getTriageExpressions().getExpressions()
- .entrySet()
- .stream()
- .collect(Collectors.toMap(
- e -> e.getKey(),
- e -> execute(e.getValue(), "result/triage")));
-
- // execute the 'groupBy' expression(s) - can refer to value of
'result' expression
- List<Object> groups = execute(definition.getGroupBy(),
ImmutableMap.of("result", profileValue), "groupBy");
+ try {
+ // execute the 'profile' expression(s)
+ Object profileValue =
execute(definition.getResult().getProfileExpressions().getExpression(),
"result/profile");
+
+ // execute the 'triage' expression(s)
+ Map<String, Object> triageValues =
definition.getResult().getTriageExpressions().getExpressions()
+ .entrySet()
+ .stream()
+ .collect(Collectors.toMap(
+ e -> e.getKey(),
+ e -> execute(e.getValue(), "result/triage")));
+
+ // execute the 'groupBy' expression(s) - can refer to value of
'result' expression
+ List<Object> groups = execute(definition.getGroupBy(),
ImmutableMap.of("result", profileValue), "groupBy");
+
+ result = Optional.of(new ProfileMeasurement()
+ .withProfileName(profileName)
+ .withEntity(entity)
+ .withGroups(groups)
+ .withPeriod(clock.currentTimeMillis(), periodDurationMillis,
TimeUnit.MILLISECONDS)
+ .withProfileValue(profileValue)
+ .withTriageValues(triageValues)
+ .withDefinition(definition));
+
+ } catch(Exception e) {
--- End diff --
Should this be a Throwable?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---