-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging for exceptions #4942
Conversation
Signed-off-by: Srikanth Govindarajan <srigovs@amazon.com>
|
||
static { | ||
EVENT.add(SENSITIVE); | ||
NOISY.add(SENSITIVE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want this relationship. A log may be noisy without being sensitive.
@@ -84,7 +83,7 @@ public Collection<Record<Event>> execute(final Collection<Record<Event>> records | |||
.build(); | |||
modifiedRecords.add(new Record<>(newRecordEvent)); | |||
} catch (JsonProcessingException e) { | |||
LOG.error(EVENT, "Unable to process Event data: {}", eventJson, e); | |||
LOG.error(NOISY, "Unable to process Event data: {}", eventJson, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this to use fluent logging such that it applies both markers.
See the description in #4927.
It will probably look like:
LOG.atError()
.addMarker(SENSITIVE)
.addMarker(NOISY)
.setMessage("Unable to process Event data: {}")
.addArgument(eventJson)
.addArgument(e)
.log();
@@ -105,7 +104,7 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
} | |||
} catch (final IOException e) { | |||
csvInvalidEventsCounter.increment(); | |||
LOG.error(EVENT, "An exception occurred while reading event [{}]", event, e); | |||
LOG.error(NOISY, "An exception occurred while reading event [{}]", event, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
@@ -72,7 +72,7 @@ public Collection<Record<Event>> doExecute(Collection<Record<Event>> records) { | |||
} | |||
} | |||
} catch (Exception ex){ | |||
LOG.error(EVENT, "Error dissecting the event [{}] ", record.getData(), ex); | |||
LOG.error(NOISY, "Error dissecting the event [{}] ", record.getData(), ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
@@ -153,11 +152,11 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
|
|||
} catch (final TimeoutException e) { | |||
event.getMetadata().addTags(tagsOnTimeout); | |||
LOG.error(EVENT, "Matching on record [{}] took longer than [{}] and timed out", record.getData(), grokProcessorConfig.getTimeoutMillis()); | |||
LOG.error(NOISY, "Matching on record [{}] took longer than [{}] and timed out", record.getData(), grokProcessorConfig.getTimeoutMillis()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
recordEvent.getMetadata().addTags(config.getTagsOnFailure()); | ||
} | ||
} catch (final Exception e) { | ||
LOG.error(EVENT, "There was an exception while processing Event [{}]", recordEvent, e); | ||
LOG.error(NOISY, "There was an exception while processing Event [{}]", recordEvent, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
@@ -70,7 +69,7 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
} | |||
} | |||
} catch (final Exception e) { | |||
LOG.error(EVENT, "There was an exception while processing Event [{}]", recordEvent, e); | |||
LOG.error(NOISY, "There was an exception while processing Event [{}]", recordEvent, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need both the log statements for the same error?
@@ -37,7 +36,7 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor | |||
try { | |||
performStringAction(recordEvent); | |||
} catch (final Exception e) { | |||
LOG.error(EVENT, "There was an exception while processing Event [{}]", recordEvent, e); | |||
LOG.error(NOISY, "There was an exception while processing Event [{}]", recordEvent, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need both the log lines for the same message?
@@ -67,7 +66,7 @@ public Collection<Record<Event>> doExecute(Collection<Record<Event>> records) { | |||
translateSource(sourceObject, recordEvent, targetConfig); | |||
} | |||
} catch (Exception ex) { | |||
LOG.error(EVENT, "Error mapping the source [{}] of entry [{}]", mappingConfig.getSource(), | |||
LOG.error(NOISY, "Error mapping the source [{}] of entry [{}]", mappingConfig.getSource(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment about using fluent logging to apply both markers.
@@ -34,7 +35,7 @@ public Collection<Record<?>> execute(final Collection<Record<?>> records) { | |||
try { | |||
Thread.sleep(delayDuration.toMillis()); | |||
} catch (final InterruptedException ex) { | |||
LOG.error("Interrupted during delay processor", ex); | |||
LOG.error(NOISY,"Interrupted during delay processor", ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the formatting to include a space after the comma. ...NOISY, "Interrupted...
.
Signed-off-by: Srikanth Govindarajan <srigovs@amazon.com>
@@ -99,7 +99,12 @@ public ObfuscationProcessor(final PluginMetrics pluginMetrics, | |||
Pattern p = Pattern.compile(rawPattern); | |||
patterns.add(p); | |||
} catch (Exception e) { | |||
LOG.error(e.getMessage()); | |||
LOG.error(NOISY,e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a few comments. Please take a look.
Signed-off-by: Srikanth Govindarajan <srigovs@amazon.com>
Description
Add noisy marker to logs that occur repeatedly.
Notes:
setCause(e) is specifically for logging an exception with its full stack trace.
addArgument(e) treats the exception as a regular argument, and typically logs only the exception’s message (or whatever toString() provides).
Issues Resolved
Resolves #4927
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.