3
3
import com .exceptionless .exceptionlessclient .configuration .ConfigurationManager ;
4
4
import com .exceptionless .exceptionlessclient .models .Event ;
5
5
import com .exceptionless .exceptionlessclient .models .EventPluginContext ;
6
- import com .exceptionless .exceptionlessclient .models .services .error .Error ;
7
- import com .exceptionless .exceptionlessclient .models .services .error .InnerError ;
8
6
import com .exceptionless .exceptionlessclient .plugins .EventPluginIF ;
9
7
import com .exceptionless .exceptionlessclient .plugins .MergedEvent ;
10
8
import lombok .Builder ;
14
12
15
13
import java .util .*;
16
14
17
- public class DuplicateErrorCheckerPlugin implements EventPluginIF {
18
- private static final Logger LOG = LoggerFactory .getLogger (DuplicateErrorCheckerPlugin .class );
15
+ public class DuplicateCheckerPlugin implements EventPluginIF {
16
+ private static final Logger LOG = LoggerFactory .getLogger (DuplicateCheckerPlugin .class );
19
17
private static final String MERGED_EVENTS_RESUBMISSION_TIMER_NAME =
20
18
"merged-events-resubmission-timer" ;
21
19
private static final Integer DEFAULT_PRIORITY = 1010 ;
@@ -29,7 +27,7 @@ public class DuplicateErrorCheckerPlugin implements EventPluginIF {
29
27
private final Integer mergedEventsResubmissionInSecs ;
30
28
31
29
@ Builder
32
- public DuplicateErrorCheckerPlugin (
30
+ public DuplicateCheckerPlugin (
33
31
Integer mergedEventsResubmissionInSecs , Integer maxHashesCount ) {
34
32
this .maxHashesCount = maxHashesCount == null ? DEFAULT_MAX_HASHES_COUNT : maxHashesCount ;
35
33
this .mergedEvents = new ArrayDeque <>();
@@ -70,13 +68,7 @@ public int getPriority() {
70
68
public void run (
71
69
EventPluginContext eventPluginContext , ConfigurationManager configurationManager ) {
72
70
Event event = eventPluginContext .getEvent ();
73
- Optional <Error > maybeError = event .getError ();
74
- if (maybeError .isEmpty ()) {
75
- return ;
76
- }
77
- Error error = maybeError .get ();
78
-
79
- long hash = getHashCode (error );
71
+ long hash = getHash (event );
80
72
Optional <MergedEvent > maybeMergedEvent =
81
73
mergedEvents .stream ().filter (mergedEvent -> mergedEvent .getHash () == hash ).findFirst ();
82
74
if (maybeMergedEvent .isPresent ()) {
@@ -119,13 +111,14 @@ private void addNewHashIfPossible(long hash, long now) {
119
111
hashes .add (TimeStampedHash .builder ().hash (hash ).timestamp (now ).build ());
120
112
}
121
113
122
- private long getHashCode (InnerError error ) {
123
- long hash = 0L ;
124
- while (error != null ) {
125
- hash += Objects .hash (error .getMessage (), error .getStackTrace ());
126
- error = error .getInner ();
127
- }
128
- return hash ;
114
+ private long getHash (Event event ) {
115
+ return Objects .hash (
116
+ event .getType (),
117
+ event .getSource (),
118
+ event .getDate (),
119
+ event .getTags (),
120
+ event .getMessage (),
121
+ event .getData ());
129
122
}
130
123
131
124
@ Builder
0 commit comments