Skip to content

Commit 8c7a7e5

Browse files
committed
add JavaDoc, update CHANGELOG.md, don't consider event.exceptions
1 parent 598770d commit 8c7a7e5

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Features
66

77
- Add `options.ignoredErrors` to filter out errors that match a certain String or Regex ([#4083](https://github.com/getsentry/sentry-java/pull/4083))
8+
- The matching is attempted on `event.message`, `event.formatted`, and `{event.throwable.class.name}: {event.throwable.message}`
89
- Can be set in `sentry.properties`, e.g. `ignored-errors=Some error,Another .*`
910
- Can be set in environment variables, e.g. `SENTRY_IGNORED_ERRORS=Some error,Another .*`
1011
- For Spring Boot, it can be set in `application.properties`, e.g. `sentry.ignored-errors=Some error,Another .*`

sentry/src/main/java/io/sentry/SentryClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private boolean shouldApplyScopeData(final @NotNull CheckIn event, final @NotNul
117117
.getLogger()
118118
.log(
119119
SentryLevel.DEBUG,
120-
"Event was dropped as the error %s is ignored",
120+
"Event was dropped as it matched a string/pattern in ignoredErrors",
121121
event.getMessage());
122122
options
123123
.getClientReportRecorder()

sentry/src/main/java/io/sentry/SentryOptions.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,10 +1578,26 @@ boolean containsIgnoredExceptionForType(final @NotNull Throwable throwable) {
15781578
return this.ignoredExceptionsForType.contains(throwable.getClass());
15791579
}
15801580

1581+
/**
1582+
* Returns the list of strings/regex patterns that `event.message`, `event.formatted`, and
1583+
* `{event.throwable.class.name}: {event.throwable.message}` are checked against to determine if
1584+
* an event shall be sent to Sentry or ignored.
1585+
*
1586+
* @return the list of strings/regex patterns that `event.message`, `event.formatted`, and
1587+
* `{event.throwable.class.name}: {event.throwable.message}` are checked against to determine
1588+
* if an event shall be sent to Sentry or ignored
1589+
*/
15811590
public @Nullable List<FilterString> getIgnoredErrors() {
15821591
return ignoredErrors;
15831592
}
15841593

1594+
/**
1595+
* Sets the list of strings/regex patterns that `event.message`, `event.formatted`, and
1596+
* `{event.throwable.class.name}: {event.throwable.message}` are checked against to determine if
1597+
* an event shall be sent to Sentry or ignored.
1598+
*
1599+
* @param ignoredErrors the list of strings/regex patterns
1600+
*/
15851601
public void setIgnoredErrors(final @Nullable List<String> ignoredErrors) {
15861602
if (ignoredErrors == null) {
15871603
this.ignoredErrors = null;
@@ -1597,6 +1613,13 @@ public void setIgnoredErrors(final @Nullable List<String> ignoredErrors) {
15971613
}
15981614
}
15991615

1616+
/**
1617+
* Adds an item to the list of strings/regex patterns that `event.message`, `event.formatted`, and
1618+
* `{event.throwable.class.name}: {event.throwable.message}` are checked against to determine if
1619+
* an event shall be sent to Sentry or ignored.
1620+
*
1621+
* @param pattern the string/regex pattern
1622+
*/
16001623
public void addIgnoredError(final @NotNull String pattern) {
16011624
if (ignoredErrors == null) {
16021625
ignoredErrors = new ArrayList<>();

sentry/src/main/java/io/sentry/util/ErrorUtils.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import io.sentry.FilterString;
44
import io.sentry.SentryEvent;
55
import io.sentry.protocol.Message;
6-
import io.sentry.protocol.SentryException;
76
import java.util.HashSet;
87
import java.util.List;
98
import java.util.Set;
@@ -34,17 +33,6 @@ public static boolean isIgnored(
3433
possibleMessages.add(formattedMessage);
3534
}
3635
}
37-
final @Nullable List<SentryException> exceptions = event.getExceptions();
38-
if (exceptions != null && !exceptions.isEmpty()) {
39-
for (final @Nullable SentryException exception : exceptions) {
40-
if (exception != null) {
41-
final @Nullable String value = exception.getValue();
42-
if (value != null) {
43-
possibleMessages.add(value);
44-
}
45-
}
46-
}
47-
}
4836
final @Nullable Throwable throwable = event.getThrowable();
4937
if (throwable != null) {
5038
possibleMessages.add(throwable.toString());

0 commit comments

Comments
 (0)