Skip to content

Commit 5e315cc

Browse files
committed
Merge pull request #91 from exceptionless/deduplication
Set the event date to the largest date when deduplicating
2 parents 12e279b + 7832d3c commit 5e315cc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Source/Shared/Plugins/Default/1010_DuplicateCheckerPlugin.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,18 @@ public DuplicateCheckerPlugin(TimeSpan? interval) {
2727
_interval = interval ?? TimeSpan.FromSeconds(60);
2828
_timer = new Timer(OnTimer, null, _interval, _interval);
2929
}
30-
30+
3131
public void Run(EventPluginContext context) {
3232
int hashCode = context.Event.GetHashCode();
3333
int count = context.Event.Count ?? 1;
3434
context.Log.FormattedTrace(typeof(DuplicateCheckerPlugin), String.Concat("Checking event: ", context.Event.Message, " with hash: ", hashCode));
35-
35+
3636
lock (_lock) {
3737
// Increment the occurrence count if the event is already queued for submission.
3838
var merged = _mergedEvents.FirstOrDefault(s => s.HashCode == hashCode);
3939
if (merged != null) {
4040
merged.IncrementCount(count);
41+
merged.UpdateDate(context.Event.Date);
4142
context.Log.FormattedInfo(typeof(DuplicateCheckerPlugin), String.Concat("Ignoring duplicate event with hash:", hashCode));
4243
context.Cancel = true;
4344
return;
@@ -59,7 +60,7 @@ public void Run(EventPluginContext context) {
5960
_processed.Dequeue();
6061
}
6162
}
62-
63+
6364
private void OnTimer(object state) {
6465
EnqueueMergedEvents();
6566
}
@@ -100,6 +101,11 @@ public void Resubmit() {
100101
_context.Event.Count = _count;
101102
_context.Resolver.GetEventQueue().Enqueue(_context.Event);
102103
}
104+
105+
public void UpdateDate(DateTimeOffset date) {
106+
if (date > _context.Event.Date)
107+
_context.Event.Date = date;
108+
}
103109
}
104110
}
105-
}
111+
}

0 commit comments

Comments
 (0)