update - 错误报告器新增动态过滤功能
This commit is contained in:
parent
83d438a6cf
commit
cdaa42efd9
@ -3,6 +3,7 @@ package cn.axzo.workflow.server.common.aspectj;
|
||||
import cn.axzo.workflow.core.common.event.ApiLogEvent;
|
||||
import cn.axzo.workflow.server.common.annotation.EnvConfig;
|
||||
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
|
||||
import cn.axzo.workflow.server.common.config.property.WorkflowProperties;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
@ -44,6 +45,8 @@ public class ErrorReportAspect implements Ordered {
|
||||
private Long apiTimeout;
|
||||
@Resource
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
@Resource
|
||||
private WorkflowProperties workflowProperties;
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
@ -111,7 +114,7 @@ public class ErrorReportAspect implements Ordered {
|
||||
log.info("ErrorReportAspect 记录异常信息: {}", e.getMessage());
|
||||
EnvConfig[] envConfigs = errorReporter.envConfig();
|
||||
for (EnvConfig envConfig : envConfigs) {
|
||||
if (Arrays.asList(envConfig.profiles()).contains(profile)) {
|
||||
if (Arrays.asList(envConfig.profiles()).contains(profile) && !workflowProperties.getFilterOperations().contains(operation.summary())) {
|
||||
envConfig.type().executeAction(profile, operation.summary(), sendDingTalk, joinPoint.getArgs(), joinPoint.getSignature().toShortString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.workflow.server.common.config.property;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 本服务的一些配置,可通过 @RefreshScope 刷新
|
||||
* <p>
|
||||
* 可全局搜索 {@code workflow.} 查看有哪些, 这里仅简单的支持需要刷新的
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/4/22 14:09
|
||||
*/
|
||||
|
||||
@RefreshScope
|
||||
@Configuration
|
||||
@ConfigurationProperties("workflow")
|
||||
@Data
|
||||
public class WorkflowProperties {
|
||||
|
||||
private List<String> filterOperations;
|
||||
|
||||
}
|
||||
@ -6,9 +6,12 @@ import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiRobotSendRequest;
|
||||
import com.dingtalk.api.response.OapiRobotSendResponse;
|
||||
import lombok.SneakyThrows;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
|
||||
|
||||
/**
|
||||
* 钉钉告警处理
|
||||
*
|
||||
@ -29,7 +32,8 @@ public class DingTalkUtils {
|
||||
markdown.setText("#### [" + profile + "]" + title + "\n" +
|
||||
"> 入参: " + JSONUtil.toJsonStr(req) + "\n\n" +
|
||||
"> ###### 异常信息: " + JSONUtil.toJsonStr(Objects.isNull(throwable.getCause()) ? throwable.getMessage() :
|
||||
throwable.getCause().getMessage()) + " \n");
|
||||
throwable.getCause().getMessage()) + " \n\n" +
|
||||
"> ##### traceId: " + MDC.get(CTX_LOG_ID_MDC) + " \n");
|
||||
request.setMarkdown(markdown);
|
||||
sendDingTalk(request);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user