Skip to content

Commit

Permalink
[BE] ๐Ÿ“ docs : thread, cpu log ์„ค์ • #559
Browse files Browse the repository at this point in the history
๐Ÿ“ docs : thread, cpu log ์„ค์ • #559
  • Loading branch information
hobeen-kim authored Oct 19, 2023
2 parents 98becc0 + 1fc6638 commit c434e00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ decorator:
enable-logging: false

warmup:
is-completed: true
is-completed: false

0 comments on commit c434e00

Please sign in to comment.