Browse Source

Pull request #8201: REPORT-67131 异步埋点调整

Merge in DESIGN/design from ~BRYANT/design:feature/x to feature/x

* commit 'cd480094e1672b72b0901e664c2ad019dcb0ffdc':
  REPORT-67131 异步埋点调整
feature/x
Bryant 3 years ago
parent
commit
4935f12f52
  1. 26
      designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java

26
designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java

@ -1,15 +1,14 @@
package com.fr.design.record.analyzer.advice;
import com.fr.concurrent.FineExecutors;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.record.analyzer.DesignerAnalyzerAdvice;
import com.fr.general.GeneralUtils;
import com.fr.intelli.measure.Estimator;
import com.fr.intelli.metrics.Compute;
import com.fr.intelli.metrics.RecordTask;
import com.fr.intelli.metrics.SupervisoryConfig;
import com.fr.intelli.record.Measurable;
import com.fr.intelli.record.MeasureObject;
import com.fr.intelli.record.MeasureUnit;
import com.fr.intelli.record.MetricRegistry;
import com.fr.measure.DBMeterFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
@ -26,7 +25,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -37,8 +35,6 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice {
private static final Pattern P = Pattern.compile("-?\\d+");
private static final int MIN_ERROR_CODE = 10000000;
public static ExecutorService executorService = FineExecutors.newCachedThreadPool(new
NamedThreadFactory(MonitorAdvice.class));
@Advice.OnMethodEnter
public static void onMethodEnter(@Advice.Origin Method method,
@ -88,8 +84,22 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice {
if (provider != null) {
sessionID = provider.getSessionID();
}
RecordTask task = new RecordTask(measurable, measureObject, sessionID, newArgs);
executorService.submit(task);
if (measurable instanceof Estimator) {
measurable.asyncDurable(measureObject, newArgs.toArray());
} else {
Object message;
try {
message = measurable.durableEntity(measureObject, newArgs.toArray());
} catch (Throwable throwable) {
//埋点生成失败,降级逻辑
message = measurable.fallBackEntity();
}
if (StringUtils.isEmpty(sessionID)) {
MetricRegistry.getMetric().submit(message);
} else {
MetricRegistry.getMetric().submitAccumulativeData(sessionID, message);
}
}
}
} catch (Exception ignore) {
//埋点信息入库失败应该不能影响业务流程

Loading…
Cancel
Save