-
-
Notifications
You must be signed in to change notification settings - Fork 23
Feature/deduplication #58
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
Changes from 5 commits
fd0f3bb
0fc7f0c
7c12490
c609e4c
1e57e9e
93b29f0
8a1ebc3
0f8261a
e41652d
b3419f1
4cfc5fa
fff0f69
09cd805
06d81f2
ef44761
e2968cc
1bbe4bf
2a35c09
f7c9b2d
b26971a
bf1baab
be062f7
63c94a1
66f40c3
cdf55c8
bb0414d
9651726
ef5f477
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { EventPluginContext } from '../EventPluginContext'; | |
import { Utils } from '../../Utils'; | ||
|
||
export class DuplicateCheckerPlugin implements IEventPlugin { | ||
public priority: number = 90; | ||
public priority: number = 1010; | ||
public name: string = 'DuplicateCheckerPlugin'; | ||
|
||
private _mergedEvents: MergedEvent[] = []; | ||
|
@@ -28,8 +28,10 @@ export class DuplicateCheckerPlugin implements IEventPlugin { | |
let hashCode = 0; | ||
|
||
while (error) { | ||
if (error.stack_trace && error.stack_trace.length) { | ||
hashCode = (hashCode * 397) ^ Utils.getHashCode(JSON.stringify(error.stack_trace)); | ||
hashCode += (hashCode * 397) ^ Utils.getHashCode(error.message); | ||
|
||
if (error.stack_trace && error.stack_trace.length) { | ||
hashCode += (hashCode * 397) ^ Utils.getHashCode(JSON.stringify(error.stack_trace)); | ||
} | ||
error = error.inner; | ||
} | ||
|
@@ -39,6 +41,7 @@ export class DuplicateCheckerPlugin implements IEventPlugin { | |
|
||
let error = context.event.data['@error']; | ||
let hashCode = getHashCode(error); | ||
|
||
if (!hashCode) { | ||
return; | ||
} | ||
|
@@ -50,16 +53,19 @@ export class DuplicateCheckerPlugin implements IEventPlugin { | |
if (merged) { | ||
merged.incrementCount(count); | ||
merged.updateDate(context.event.date); | ||
context.log.info("Ignoring duplicate event with hash: " + hashCode); | ||
context.cancelled = true; | ||
return; | ||
} | ||
|
||
if (this._processedHashcodes.some(h => h.hash === hashCode && h.timestamp >= (now - this._interval))) { | ||
context.log.info("Adding event with hash: " + hashCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a trace level message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only have these:
|
||
this._mergedEvents.push(new MergedEvent(hashCode, context, count)); | ||
context.cancelled = true; | ||
return; | ||
} | ||
|
||
context.log.info("Enqueueing event with hash: " + hashCode + "to cache."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a trace level message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only have:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess we could add trace (https://github.com/DeveloperToolsWG/console-object/blob/master/api.md#consolelogobject--object-) doesn't look like it's supported everywhere. We'd have to wrap it like we are doing the other ones I guess. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
this._processedHashcodes.push({ hash: hashCode, timestamp: now }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be nice if we added some minimal logging to this class. Makes it much easier to debug issues There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
// Only keep the last 50 recent errors. | ||
|
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 you think we should be checking the message length as well? Os should getHashCode method check that?
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.
Added it, just in case :)