小编Jua*_*vid的帖子

与哨兵分组

我想用Sentry对异常进行分组,该异常来自不同的服务器,但是我希望所有异常按类型分类在一起,例如,将所有NPE分组。我知道您可以扩展EventBuilderHelper,这就是哨兵分组的方式,但是哨兵java不提供发送带有方法,错误类型等指纹的事件的功能,就像docs.sentry.io中的其他SDK一样

function makeRequest(method, path, options) {
    return fetch(method, path, options).catch(err => {
        Sentry.withScope(scope => {
          // group errors together based on their request and response
          scope.setFingerprint([method, path, err.statusCode]);
          Sentry.captureException(err);
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

这是我尝试做的,但是在这个范围内,没有关于方法,错误等的知识。

package com.test;

import io.sentry.SentryClient;
import io.sentry.event.EventBuilder;
import io.sentry.event.helper.ContextBuilderHelper;

public class FingerprintEventBuilderHelper extends ContextBuilderHelper {

    private static final String EXCEPTION_TYPE = "exception_type";

    public FingerprintEventBuilderHelper(SentryClient sentryClient) {
        super(sentryClient);
    }

    @Override
    public void helpBuildingEvent(EventBuilder eventBuilder) {
        super.helpBuildingEvent(eventBuilder);
        //Get the exception type
        String exceptionType =
        if (exceptionType != null) {
            eventBuilder.withTag(EXCEPTION_TYPE, …
Run Code Online (Sandbox Code Playgroud)

java java-ee sentry

5
推荐指数
1
解决办法
171
查看次数

标签 统计

java ×1

java-ee ×1

sentry ×1