|
|
@ -1,13 +1,15 @@ |
|
|
|
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.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; |
|
|
@ -24,6 +26,7 @@ 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; |
|
|
|
|
|
|
|
|
|
|
@ -34,6 +37,8 @@ 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; |
|
|
|
|
|
|
|
private 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, |
|
|
@ -75,24 +80,16 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice { |
|
|
|
measureObject.consume(consume); |
|
|
|
measureObject.consume(consume); |
|
|
|
measureObject.error(error); |
|
|
|
measureObject.error(error); |
|
|
|
String id = UUID.randomUUID().toString(); |
|
|
|
String id = UUID.randomUUID().toString(); |
|
|
|
List<Object> newArgs = new ArrayList<Object>(Arrays.asList(args)); |
|
|
|
List<Object> newArgs = new ArrayList<>(Arrays.asList(args)); |
|
|
|
newArgs.add(id); |
|
|
|
newArgs.add(id); |
|
|
|
recordSQLDetail(id); |
|
|
|
recordSQLDetail(id); |
|
|
|
Object message; |
|
|
|
String sessionID = null; |
|
|
|
try { |
|
|
|
SessionProvider provider = SessionLocalManager.getSession(); |
|
|
|
message = measurable.durableEntity(measureObject, newArgs.toArray()); |
|
|
|
if (provider != null) { |
|
|
|
} catch (Throwable ignore) { |
|
|
|
sessionID = provider.getSessionID(); |
|
|
|
//埋点生成失败,降级逻辑
|
|
|
|
|
|
|
|
message = measurable.fallBackEntity(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (message != null) { |
|
|
|
|
|
|
|
SessionProvider provider = SessionLocalManager.getSession(); |
|
|
|
|
|
|
|
if (provider == null) { |
|
|
|
|
|
|
|
MetricRegistry.getMetric().submit(message); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
MetricRegistry.getMetric().submitAccumulativeData(provider.getSessionID(), message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RecordTask task = new RecordTask(measurable, measureObject, sessionID, newArgs); |
|
|
|
|
|
|
|
executorService.submit(task); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception ignore) { |
|
|
|
} catch (Exception ignore) { |
|
|
|
//埋点信息入库失败应该不能影响业务流程
|
|
|
|
//埋点信息入库失败应该不能影响业务流程
|
|
|
|