33import com .exceptionless .exceptionlessclient .configuration .ConfigurationManager ;
44import com .exceptionless .exceptionlessclient .models .Event ;
55import com .exceptionless .exceptionlessclient .models .EventPluginContext ;
6- import com .exceptionless .exceptionlessclient .models .services .error .Error ;
7- import com .exceptionless .exceptionlessclient .models .services .error .InnerError ;
86import com .exceptionless .exceptionlessclient .plugins .EventPluginIF ;
97import com .exceptionless .exceptionlessclient .plugins .MergedEvent ;
108import lombok .Builder ;
1412
1513import java .util .*;
1614
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 );
1917 private static final String MERGED_EVENTS_RESUBMISSION_TIMER_NAME =
2018 "merged-events-resubmission-timer" ;
2119 private static final Integer DEFAULT_PRIORITY = 1010 ;
@@ -29,7 +27,7 @@ public class DuplicateErrorCheckerPlugin implements EventPluginIF {
2927 private final Integer mergedEventsResubmissionInSecs ;
3028
3129 @ Builder
32- public DuplicateErrorCheckerPlugin (
30+ public DuplicateCheckerPlugin (
3331 Integer mergedEventsResubmissionInSecs , Integer maxHashesCount ) {
3432 this .maxHashesCount = maxHashesCount == null ? DEFAULT_MAX_HASHES_COUNT : maxHashesCount ;
3533 this .mergedEvents = new ArrayDeque <>();
@@ -70,13 +68,7 @@ public int getPriority() {
7068 public void run (
7169 EventPluginContext eventPluginContext , ConfigurationManager configurationManager ) {
7270 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 );
8072 Optional <MergedEvent > maybeMergedEvent =
8173 mergedEvents .stream ().filter (mergedEvent -> mergedEvent .getHash () == hash ).findFirst ();
8274 if (maybeMergedEvent .isPresent ()) {
@@ -119,13 +111,14 @@ private void addNewHashIfPossible(long hash, long now) {
119111 hashes .add (TimeStampedHash .builder ().hash (hash ).timestamp (now ).build ());
120112 }
121113
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 ());
129122 }
130123
131124 @ Builder
0 commit comments