[server/logging] intercept ECONNRESET messages and downgrade them#8785
[server/logging] intercept ECONNRESET messages and downgrade them#8785spalger merged 6 commits intoelastic:masterfrom
Conversation
src/server/logging/do_tags_match.js
Outdated
| } | ||
|
|
||
| const unmatchedEventTags = event.tags.slice(0); | ||
| const unmatchedExpectedTags = []; |
There was a problem hiding this comment.
The tags seem to have a perceived order. Is there a reason for not requiring the order to match as well?
There was a problem hiding this comment.
If we require the order to match, I think we could potentially use _.isEqual
There was a problem hiding this comment.
I suppose I could sort and then use _.isEqual, sounds good to me!
There was a problem hiding this comment.
I am thinking we don't even need to sort. The expected tags would need to match the order of the events tags. Trying to not do more than we need to.
kobelb
left a comment
There was a problem hiding this comment.
LGTM
One minor question/suggestion
src/server/logging/do_tags_match.js
Outdated
| if (i > -1) { | ||
| unmatchedEventTags.splice(i, 1); | ||
| } else { | ||
| unmatchedExpectedTags.push(t); |
There was a problem hiding this comment.
Could we just return false here?
src/server/logging/do_tags_match.js
Outdated
| } | ||
| }); | ||
|
|
||
| return unmatchedEventTags.concat(unmatchedExpectedTags).length === 0; |
There was a problem hiding this comment.
We could check if the length of unmatchedEventTags is 0
There was a problem hiding this comment.
Hmm, I suppose we could, since the lengths of both arrays is the same.
| import { get, isEqual, sortBy } from 'lodash'; | ||
|
|
||
| function doTagsMatch(event, tags) { | ||
| return isEqual(sortBy(get(event, 'tags')), sortBy(tags)); |
There was a problem hiding this comment.
Repeating here since my comment is hidden after the last update:
Is there a reason why we need to support not matching the order?
There was a problem hiding this comment.
We don't control the code that sends the tags, and I don't see why we wouldn't.
There was a problem hiding this comment.
It just doesn't seem necessary to add the additional overhead while limiting control. Should the tag order change in Hapi we can always update them. In the future if we want to be less greedy with the matching we can then sort.
|
LGTM |
| @@ -0,0 +1,55 @@ | |||
| import expect from 'expect.js'; | |||
| import { shuffle } from 'lodash'; | |||
There was a problem hiding this comment.
shuffle is no longer being used.
| * @param {object} - log event | ||
| */ | ||
| downgradeIfEconnreset(event) { | ||
| const isClientError = doTagsMatch(event, ['error', 'client', 'connection']); |
There was a problem hiding this comment.
Hapi is using the following order ['connection', 'client', 'error'] per https://github.com/hapijs/hapi/blob/master/lib/connection.js#L96
There was a problem hiding this comment.
ugh, I looked at the order in the log output, which is sorted by color I think :/
There was a problem hiding this comment.
Good catch! I have seen it so much today it's just a blur.
|
LGTM - Ship It!! |
--------- **Commit 1:** [server/logging] intercept ECONNRESET messages and downgrade them * Original sha: 38bcad9 * Authored by spalger <email@spalger.com> on 2016-10-20T19:24:16Z **Commit 2:** [server/logging] remove doTagsMatch() helper * Original sha: a8eea58 * Authored by spalger <email@spalger.com> on 2016-10-20T20:19:33Z **Commit 3:** [server/logging] add tests for log interceptor * Original sha: 866abcc * Authored by spalger <email@spalger.com> on 2016-10-20T20:35:35Z **Commit 4:** [server/logging] only match tags that are in the right order * Original sha: 1973ed8 * Authored by spalger <email@spalger.com> on 2016-10-20T20:50:26Z **Commit 5:** [server/logging] remove unused dependency * Original sha: dbe5f6f * Authored by spalger <email@spalger.com> on 2016-10-20T20:58:59Z **Commit 6:** [server/logging] fix the order we expect tags to be in * Original sha: 76e09e6 * Authored by spalger <email@spalger.com> on 2016-10-20T21:04:58Z
--------- **Commit 1:** [server/logging] intercept ECONNRESET messages and downgrade them * Original sha: 38bcad9 * Authored by spalger <email@spalger.com> on 2016-10-20T19:24:16Z **Commit 2:** [server/logging] remove doTagsMatch() helper * Original sha: a8eea58 * Authored by spalger <email@spalger.com> on 2016-10-20T20:19:33Z **Commit 3:** [server/logging] add tests for log interceptor * Original sha: 866abcc * Authored by spalger <email@spalger.com> on 2016-10-20T20:35:35Z **Commit 4:** [server/logging] only match tags that are in the right order * Original sha: 1973ed8 * Authored by spalger <email@spalger.com> on 2016-10-20T20:50:26Z **Commit 5:** [server/logging] remove unused dependency * Original sha: dbe5f6f * Authored by spalger <email@spalger.com> on 2016-10-20T20:58:59Z **Commit 6:** [server/logging] fix the order we expect tags to be in * Original sha: 76e09e6 * Authored by spalger <email@spalger.com> on 2016-10-20T21:04:58Z
[backport] PR #8785 to 5.0 - [server/logging] intercept ECONNRESET messages and downgrade them
[backport] PR #8785 to 5.x - [server/logging] intercept ECONNRESET messages and downgrade them
With the latest node/hapi upgrades, ECONNRESET errors are being logged whereas they weren't before.
|
4.6 9f5cf2c |
--------- **Commit 1:** [server/logging] intercept ECONNRESET messages and downgrade them * Original sha: 77dc71aa714369e40f3660c655b9e08b00010699 [formerly 38bcad9] * Authored by spalger <email@spalger.com> on 2016-10-20T19:24:16Z **Commit 2:** [server/logging] remove doTagsMatch() helper * Original sha: 0bde8381146b8c4d391360cb4d5feda9b1e3d3cd [formerly a8eea58] * Authored by spalger <email@spalger.com> on 2016-10-20T20:19:33Z **Commit 3:** [server/logging] add tests for log interceptor * Original sha: 6c529b0f47582bc863f025f5fe83b07f59af6fd8 [formerly 866abcc] * Authored by spalger <email@spalger.com> on 2016-10-20T20:35:35Z **Commit 4:** [server/logging] only match tags that are in the right order * Original sha: 04b7da8b4cb502e25fc65714c3e8fa9cba5725ca [formerly 1973ed8] * Authored by spalger <email@spalger.com> on 2016-10-20T20:50:26Z **Commit 5:** [server/logging] remove unused dependency * Original sha: 7990a50ec74343b3b1a3200873132377dfbda20e [formerly dbe5f6f] * Authored by spalger <email@spalger.com> on 2016-10-20T20:58:59Z **Commit 6:** [server/logging] fix the order we expect tags to be in * Original sha: f21a523883ef26c8ca7d461c54da8d66fb0076c5 [formerly 76e09e6] * Authored by spalger <email@spalger.com> on 2016-10-20T21:04:58Z Former-commit-id: 6326821
[backport] PR elastic#8785 to 5.x - [server/logging] intercept ECONNRESET messages and downgrade them Former-commit-id: a5080ee
Fixes #8623
Implements a
LogInterceptorthat sees every log message before it is filtered by the squeeze stream. This allows us to transform log messages we might not have control over, like the log messages that come from hapi itself, before they are processed by the standard log message pipeline.