[
https://issues.apache.org/jira/browse/METRON-1121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16138382#comment-16138382
]
ASF GitHub Bot commented on METRON-1121:
----------------------------------------
Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/707#discussion_r134758762
--- 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) {
+ // if any of the Stellar expressions fail, a measurement should NOT
be returned
+ LOG.error(format("Unable to flush profile: %s", e.getMessage()));
--- End diff --
Can we pass the exception as the second argument to `LOG.error`
> Ignore Profile with Bad 'init', 'update' or 'groupBy'
> -----------------------------------------------------
>
> Key: METRON-1121
> URL: https://issues.apache.org/jira/browse/METRON-1121
> Project: Metron
> Issue Type: Bug
> Reporter: Nick Allen
> Assignee: Nick Allen
> Fix For: 0.4.1
>
>
> The Profiler needs to gracefully ignore profiles that have a bad 'init',
> 'update' or 'groupBy' expression. Under certain conditions a message may not
> be applied to all valid profiles, due to a single bad profile.
> If the Profiler is running with multiple profiles defined and one of those
> profiles has a Stellar expression that throws an exception for either the
> 'init', 'update' or 'groupBy', the current logic will not continue to attempt
> to apply the message to the remaining valid profiles. Only valid profiles
> executed before the bad profile will have the message applied. Any valid
> profiles after the bad profile will not see the message.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)