From 1fc6638a1c65e4fc4315a20d665e6ab630620937 Mon Sep 17 00:00:00 2001 From: kimhobeen Date: Thu, 19 Oct 2023 20:18:11 +0900 Subject: [PATCH] =?UTF-8?q?:memo:=20docs=20:=20thread,=20cpu=20log=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20#559?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/server/global/log/filter/MDCLoggingFilter.java | 10 ++++++++++ Server/src/main/resources/application.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Server/src/main/java/com/server/global/log/filter/MDCLoggingFilter.java b/Server/src/main/java/com/server/global/log/filter/MDCLoggingFilter.java index e3beaaa5..e22b7485 100644 --- a/Server/src/main/java/com/server/global/log/filter/MDCLoggingFilter.java +++ b/Server/src/main/java/com/server/global/log/filter/MDCLoggingFilter.java @@ -1,6 +1,7 @@ package com.server.global.log.filter; import com.server.global.initailizer.warmup.WarmupState; +import com.sun.management.OperatingSystemMXBean; import lombok.extern.slf4j.Slf4j; import org.slf4j.MDC; import org.springframework.core.Ordered; @@ -10,6 +11,7 @@ import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.lang.management.ManagementFactory; import java.util.UUID; @Component @@ -32,6 +34,14 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha long startTime = System.currentTimeMillis(); + if(warmupState.isWarmupCompleted()) { + OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class); + double sysCpuLoad = osBean.getSystemCpuLoad() * 100; + + log.info("Thread Count : {}, CPU usage : {}%", Thread.activeCount(), sysCpuLoad); + } + + chain.doFilter(request, response); long endTime = System.currentTimeMillis(); diff --git a/Server/src/main/resources/application.yml b/Server/src/main/resources/application.yml index 0c477db3..9c617382 100644 --- a/Server/src/main/resources/application.yml +++ b/Server/src/main/resources/application.yml @@ -117,5 +117,5 @@ decorator: enable-logging: false warmup: - is-completed: true + is-completed: false