-
Notifications
You must be signed in to change notification settings - Fork 1
fix(grouper): identify events similarity only when titles are same #410
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ import HawkCatcher from '@hawk.so/nodejs'; | |
| import { MS_IN_SEC } from '../../../lib/utils/consts'; | ||
| import DataFilter from './data-filter'; | ||
| import RedisHelper from './redisHelper'; | ||
| import levenshtein from 'js-levenshtein'; | ||
| import { computeDelta } from './utils/repetitionDiff'; | ||
| import TimeMs from '../../../lib/utils/time'; | ||
|
|
||
|
|
@@ -244,22 +243,24 @@ export default class GrouperWorker extends Worker { | |
| */ | ||
| private async findSimilarEvent(projectId: string, event: EventDataAccepted<EventAddons>): Promise<GroupedEventDBScheme | undefined> { | ||
| const eventsCountToCompare = 60; | ||
| const diffTreshold = 0.35; | ||
| // const diffTreshold = 0.35; | ||
|
|
||
| const lastUniqueEvents = await this.findLastEvents(projectId, eventsCountToCompare); | ||
|
|
||
| /** | ||
| * First try to find by Levenshtein distance | ||
| * First try to find similar event by title | ||
| */ | ||
| const similarByLevenshtein = lastUniqueEvents.filter(prevEvent => { | ||
| const distance = levenshtein(event.title, prevEvent.payload.title); | ||
| const threshold = event.title.length * diffTreshold; | ||
| const similarByTitle = lastUniqueEvents.filter(prevEvent => { | ||
| // const distance = levenshtein(event.title, prevEvent.payload.title); | ||
|
|
||
| return distance < threshold; | ||
| // const threshold = event.title.length * diffTreshold; | ||
|
|
||
| // return distance < threshold; | ||
| return event.title.toLowerCase() === prevEvent.payload.title.toLowerCase(); | ||
| }).pop(); | ||
|
Comment on lines
+253
to
260
Member
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. lets just comment out grouping by Levenshtein and implement grouping by title below. |
||
|
|
||
| if (similarByLevenshtein) { | ||
| return similarByLevenshtein; | ||
| if (similarByTitle) { | ||
| return similarByTitle; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -280,13 +281,14 @@ export default class GrouperWorker extends Worker { | |
| { sort: { _id: 1 } } | ||
| ); | ||
| }); | ||
|
|
||
| this.logger.info(`original event for pattern: ${JSON.stringify(originalEvent)}`); | ||
|
|
||
| if (originalEvent) { | ||
| return originalEvent; | ||
| } | ||
| } catch (e) { | ||
| this.logger.error(`Error while getting original event for pattern ${matchingPattern}`) | ||
| this.logger.error(`Error while getting original event for pattern ${matchingPattern}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -472,17 +472,17 @@ | |
| }); | ||
|
|
||
| describe('Grouping', () => { | ||
| test('should group events with partially different titles', async () => { | ||
| await worker.handle(generateTask({ title: 'Some error (but not filly identical) example' })); | ||
| await worker.handle(generateTask({ title: 'Some error (yes, it is not the identical) example' })); | ||
| await worker.handle(generateTask({ title: 'Some error (and it is not identical) example' })); | ||
| // test('should group events with partially different titles', async () => { | ||
| // await worker.handle(generateTask({ title: 'Some error (but not filly identical) example' })); | ||
| // await worker.handle(generateTask({ title: 'Some error (yes, it is not the identical) example' })); | ||
| // await worker.handle(generateTask({ title: 'Some error (and it is not identical) example' })); | ||
|
|
||
| const originalEvent = await eventsCollection.findOne({}); | ||
| // const originalEvent = await eventsCollection.findOne({}); | ||
|
|
||
| expect((await repetitionsCollection.find({ | ||
| groupHash: originalEvent.groupHash, | ||
| }).toArray()).length).toBe(2); | ||
| }); | ||
| // expect((await repetitionsCollection.find({ | ||
| // groupHash: originalEvent.groupHash, | ||
| // }).toArray()).length).toBe(2); | ||
| // }); | ||
|
|
||
|
Member
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. add test for grouping by title |
||
| describe('Pattern matching', () => { | ||
| beforeEach(() => { | ||
|
|
@@ -490,8 +490,8 @@ | |
| }); | ||
|
|
||
| test('should group events with titles matching one pattern', async () => { | ||
| jest.spyOn(GrouperWorker.prototype as any, 'getProjectPatterns').mockResolvedValue([ 'New error .*' ]); | ||
| const findMatchingPatternSpy = jest.spyOn(GrouperWorker.prototype as any, 'findMatchingPattern'); | ||
|
|
||
| await worker.handle(generateTask({ title: 'New error 0000000000000000' })); | ||
| await worker.handle(generateTask({ title: 'New error 1111111111111111' })); | ||
|
|
@@ -506,7 +506,7 @@ | |
| }); | ||
|
|
||
| test('should handle multiple patterns and match the first one that applies', async () => { | ||
| jest.spyOn(GrouperWorker.prototype as any, 'getProjectPatterns').mockResolvedValue([ | ||
| 'Database error: .*', | ||
| 'Network error: .*', | ||
| 'New error: .*', | ||
|
|
@@ -525,7 +525,7 @@ | |
| }); | ||
|
|
||
| test('should handle complex regex patterns', async () => { | ||
| jest.spyOn(GrouperWorker.prototype as any, 'getProjectPatterns').mockResolvedValue([ | ||
| 'Error \\d{3}: [A-Za-z\\s]+ in file .*\\.js$', | ||
| 'Warning \\d{3}: .*', | ||
| ]); | ||
|
|
@@ -543,7 +543,7 @@ | |
| }); | ||
|
|
||
| test('should maintain separate groups for different patterns', async () => { | ||
| jest.spyOn(GrouperWorker.prototype as any, 'getProjectPatterns').mockResolvedValue([ | ||
| 'TypeError: .*', | ||
| 'ReferenceError: .*', | ||
| ]); | ||
|
|
@@ -565,7 +565,7 @@ | |
| }); | ||
|
|
||
| test('should handle patterns with special regex characters', async () => { | ||
| jest.spyOn(GrouperWorker.prototype as any, 'getProjectPatterns').mockResolvedValue([ | ||
| 'Error \\[\\d+\\]: .*', | ||
| 'Warning \\(code=\\d+\\): .*', | ||
| ]); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably, we can find event by title using mongo. We dont need to get 60 events for that.