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