refactor(接口测试): log优化去除不必要干扰日志,增加jvm信息
This commit is contained in:
parent
a0eef18f95
commit
8d173a5513
|
@ -4,10 +4,7 @@ package io.metersphere.api.jmeter;
|
||||||
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
|
import io.metersphere.api.exec.queue.PoolExecBlockingQueueUtil;
|
||||||
import io.metersphere.api.jmeter.utils.ReportStatusUtil;
|
import io.metersphere.api.jmeter.utils.ReportStatusUtil;
|
||||||
import io.metersphere.commons.constants.CommonConstants;
|
import io.metersphere.commons.constants.CommonConstants;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.commons.utils.FileUtils;
|
|
||||||
import io.metersphere.commons.utils.FixedCapacityUtil;
|
|
||||||
import io.metersphere.commons.utils.JSON;
|
|
||||||
import io.metersphere.commons.vo.ResultVO;
|
import io.metersphere.commons.vo.ResultVO;
|
||||||
import io.metersphere.constants.BackendListenerConstants;
|
import io.metersphere.constants.BackendListenerConstants;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
|
@ -111,6 +108,8 @@ public class MsApiBackendListener extends AbstractBackendListenerClient implemen
|
||||||
apiExecutionQueueService.testPlanReportTestEnded(dto.getTestPlanReportId());
|
apiExecutionQueueService.testPlanReportTestEnded(dto.getTestPlanReportId());
|
||||||
}
|
}
|
||||||
LoggerUtil.info("TEST-END处理结果集完成", dto.getReportId());
|
LoggerUtil.info("TEST-END处理结果集完成", dto.getReportId());
|
||||||
|
|
||||||
|
JvmUtil.memoryInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LoggerUtil.error("结果集处理异常", dto.getReportId(), e);
|
LoggerUtil.error("结果集处理异常", dto.getReportId(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class MsDebugListener extends AbstractListenerElement implements SampleLi
|
||||||
LoggerUtil.debug("send. " + this.getName());
|
LoggerUtil.debug("send. " + this.getName());
|
||||||
WebSocketUtil.sendMessageSingle(dto);
|
WebSocketUtil.sendMessageSingle(dto);
|
||||||
PoolExecBlockingQueueUtil.offer(this.getName());
|
PoolExecBlockingQueueUtil.offer(this.getName());
|
||||||
|
JvmUtil.memoryInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,10 +3,7 @@ package io.metersphere.api.jmeter;
|
||||||
import io.metersphere.api.dto.MsgDTO;
|
import io.metersphere.api.dto.MsgDTO;
|
||||||
import io.metersphere.commons.constants.ApiRunMode;
|
import io.metersphere.commons.constants.ApiRunMode;
|
||||||
import io.metersphere.commons.constants.KafkaTopicConstants;
|
import io.metersphere.commons.constants.KafkaTopicConstants;
|
||||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.commons.utils.JSONUtil;
|
|
||||||
import io.metersphere.commons.utils.NamedThreadFactory;
|
|
||||||
import io.metersphere.commons.utils.WebSocketUtil;
|
|
||||||
import io.metersphere.service.ApiExecutionQueueService;
|
import io.metersphere.service.ApiExecutionQueueService;
|
||||||
import io.metersphere.service.TestResultService;
|
import io.metersphere.service.TestResultService;
|
||||||
import io.metersphere.service.definition.ApiDefinitionEnvService;
|
import io.metersphere.service.definition.ApiDefinitionEnvService;
|
||||||
|
@ -59,8 +56,8 @@ public class MsKafkaListener {
|
||||||
task.setTestResultService(testResultService);
|
task.setTestResultService(testResultService);
|
||||||
task.setRecord(item);
|
task.setRecord(item);
|
||||||
threadPool.execute(task);
|
threadPool.execute(task);
|
||||||
this.outKafkaPoolLogger();
|
|
||||||
});
|
});
|
||||||
|
JvmUtil.memoryInfo();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LoggerUtil.error("KAFKA消费失败:", e);
|
LoggerUtil.error("KAFKA消费失败:", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package io.metersphere.commons.utils;
|
||||||
|
|
||||||
|
import io.metersphere.utils.LoggerUtil;
|
||||||
|
|
||||||
|
public class JvmUtil {
|
||||||
|
|
||||||
|
public static void memoryInfo() {
|
||||||
|
int byteToMb = 1024 * 1024;
|
||||||
|
Runtime rt = Runtime.getRuntime();
|
||||||
|
long vmTotal = rt.totalMemory() / byteToMb;
|
||||||
|
long vmFree = rt.freeMemory() / byteToMb;
|
||||||
|
long vmMax = rt.maxMemory() / byteToMb;
|
||||||
|
long vmUse = vmTotal - vmFree;
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder("当前执行节点内存信息:").append("\n");
|
||||||
|
builder.append("当前JVM最大内存:" + vmMax + " M").append("\n");
|
||||||
|
builder.append("当前JVM占用的总内存:" + vmTotal + " M").append("\n");
|
||||||
|
builder.append("当前JVM空闲内存为:" + vmFree + " M").append("\n");
|
||||||
|
builder.append("当前JVM已用内存为:" + vmUse + " M").append("\n");
|
||||||
|
LoggerUtil.info(builder.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -210,40 +210,6 @@
|
||||||
<appender-ref ref="eurekaAsyncAppender"/>
|
<appender-ref ref="eurekaAsyncAppender"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
|
|
||||||
<!-- 自定义测试计划执行的日志 -->
|
|
||||||
<appender name="infoTestPlanAppender"
|
|
||||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<level>INFO</level>
|
|
||||||
</filter>
|
|
||||||
<File>${logging.file.path}/testPlan/info.log</File>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<FileNamePattern>${logging.file.path}/history/testPlan/info.%d{yyyyMMdd}-%i.log
|
|
||||||
</FileNamePattern>
|
|
||||||
<maxHistory>${logger.max.history:-30}</maxHistory>
|
|
||||||
<TimeBasedFileNamingAndTriggeringPolicy
|
|
||||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>50MB</maxFileSize>
|
|
||||||
</TimeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
<Pattern>%d %t %-5level %logger{36} %line - %msg%n</Pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
<appender name="infoTestPlanAsyncAppender" class="ch.qos.logback.classic.AsyncAppender">
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<level>INFO</level>
|
|
||||||
</filter>
|
|
||||||
<queueSize>10000</queueSize>
|
|
||||||
<appender-ref ref="infoTestPlanAppender"/>
|
|
||||||
</appender>
|
|
||||||
<logger name="testPlanExecuteLog" additivity="false">
|
|
||||||
<level value="${logger.level:INFO}"/>
|
|
||||||
<appender-ref ref="infoTestPlanAsyncAppender"/>
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<!-- 自定义执行过程日志 -->
|
<!-- 自定义执行过程日志 -->
|
||||||
<appender name="apiRunLogAppender"
|
<appender name="apiRunLogAppender"
|
||||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
|
Loading…
Reference in New Issue