java - Sentry Android:忽略不包含我的包的堆栈跟踪
问题描述
我在一个供其他开发人员使用的 Android 库中使用 Sentry。我从使用我的库的应用程序中得到了很多异常,但这些异常与库无关,并且真的很想忽略这些。有什么方法可以过滤异常,所以我只报告那些在堆栈跟踪中某处有我的库包的异常吗?
解决方案
您可以使用ShouldSendEventCallback
:
public static void example() {
SentryClient client = Sentry.getStoredClient();
client.addShouldSendEventCallback(new ShouldSendEventCallback() {
@Override
public boolean shouldSend(Event event) {
// decide whether to send the event
for (Map.Entry<String, SentryInterface> interfaceEntry : event.getSentryInterfaces().entrySet()) {
if (interfaceEntry.getValue() instanceof ExceptionInterface) {
ExceptionInterface i = (ExceptionInterface) interfaceEntry.getValue();
for (SentryException sentryException : i.getExceptions()) {
// this example checks the exception class
if (sentryException.getExceptionClassName().equals("foo")) {
// don't send the event
return false;
}
}
}
}
// send event
return true;
}
});
}
有一张票可以让这更容易:https ://github.com/getsentry/sentry-java/issues/575
推荐阅读
- eclipse-rcptt - 启动 AUT 进行录制时出错 - 超时错误:AUT 没有响应
- django - 如何在 django 中修改继承类中的登录视图?
- python - Pandas:如何按日期时间列分组,仅使用时间并丢弃日期
- html - CSS 位置 Sticky、Z-Index 和绝对定位不起作用...如何解决这个问题?
- angular - 在融合图表Angular 8中添加数据加载消息
- telegram-bot - 电报机器人:继续私下对话
- html - 链接到表格 HTML / Vuetify.js 中的特定行
- ios - 尝试从 UIImage 剪辑边缘以适合 ImageView
- r - 在零之前插入一个空白行
- docker - 将 docker-machine 作为 snap 与标准安装运行