@@ -29,11 +29,12 @@ public DuplicateCheckerPlugin(TimeSpan? interval) {
29
29
30
30
public void Run ( EventPluginContext context ) {
31
31
int hashCode = context . Event . GetHashCode ( ) ;
32
-
32
+ int count = context . Event . Count ?? 1 ;
33
+
33
34
// Increment the occurrence count if the event is already queued for submission.
34
35
var merged = _mergedEvents . FirstOrDefault ( s => s . HashCode == hashCode ) ;
35
36
if ( merged != null ) {
36
- merged . IncrementCount ( ) ;
37
+ merged . IncrementCount ( count ) ;
37
38
context . Log . FormattedInfo ( typeof ( DuplicateCheckerPlugin ) , String . Concat ( "Ignoring duplicate error event with hash:" , hashCode ) ) ;
38
39
context . Cancel = true ;
39
40
return ;
@@ -42,7 +43,7 @@ public void Run(EventPluginContext context) {
42
43
DateTimeOffset repeatWindow = DateTimeOffset . UtcNow . Subtract ( _interval ) ;
43
44
if ( _processed . Any ( s => s . Item1 == hashCode && s . Item2 >= repeatWindow ) ) {
44
45
// This event is a duplicate for the first time, lets save it so we can delay it while keeping count
45
- _mergedEvents . Enqueue ( new MergedEvent ( hashCode , context ) ) ;
46
+ _mergedEvents . Enqueue ( new MergedEvent ( hashCode , context , count ) ) ;
46
47
context . Cancel = true ;
47
48
} else {
48
49
_processed . Enqueue ( Tuple . Create ( hashCode , DateTimeOffset . UtcNow ) ) ;
@@ -73,18 +74,19 @@ public void Dispose() {
73
74
}
74
75
75
76
private class MergedEvent {
76
- private int _count = 1 ;
77
+ private int _count ;
77
78
private readonly EventPluginContext _context ;
78
79
79
- public MergedEvent ( int hashCode , EventPluginContext context ) {
80
+ public MergedEvent ( int hashCode , EventPluginContext context , int count ) {
80
81
HashCode = hashCode ;
81
82
_context = context ;
83
+ _count = count ;
82
84
}
83
85
84
86
public int HashCode { get ; private set ; }
85
87
86
- public void IncrementCount ( ) {
87
- Interlocked . Increment ( ref _count ) ;
88
+ public void IncrementCount ( int value ) {
89
+ Interlocked . Add ( ref _count , value ) ;
88
90
}
89
91
90
92
public void Enqueue ( ) {
0 commit comments