-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #783 from woowacourse-teams/develop
Hang-Log Prod 2.2.0 Release
- Loading branch information
Showing
2,260 changed files
with
62,270 additions
and
38,129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule backend-submodule
updated
from c8ac91 to 66a914
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/hanglog/global/config/AsyncConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package hanglog.global.config; | ||
|
||
import hanglog.global.decorator.MdcTaskDecorator; | ||
import hanglog.global.exception.AsyncExceptionHandler; | ||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.task.TaskExecutor; | ||
import org.springframework.scheduling.annotation.AsyncConfigurer; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
@Configuration | ||
@EnableAsync | ||
public class AsyncConfig implements AsyncConfigurer { | ||
|
||
@Bean | ||
public TaskExecutor taskExecutor() { | ||
final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); | ||
taskExecutor.setCorePoolSize(8); | ||
taskExecutor.setTaskDecorator(new MdcTaskDecorator()); | ||
taskExecutor.setThreadNamePrefix("async-task-"); | ||
return taskExecutor; | ||
} | ||
|
||
@Override | ||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { | ||
return new AsyncExceptionHandler(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/hanglog/global/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package hanglog.global.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
|
||
@Value("${spring.redis.host}") | ||
private String host; | ||
@Value("${spring.redis.port}") | ||
private int port; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
return new LettuceConnectionFactory(host, port); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
backend/src/main/java/hanglog/global/decorator/MdcTaskDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package hanglog.global.decorator; | ||
|
||
import java.util.Map; | ||
import org.slf4j.MDC; | ||
import org.springframework.core.task.TaskDecorator; | ||
|
||
public class MdcTaskDecorator implements TaskDecorator { | ||
|
||
@Override | ||
public Runnable decorate(final Runnable runnable) { | ||
final Map<String, String> copyOfContextMap = MDC.getCopyOfContextMap(); | ||
return () -> { | ||
if (copyOfContextMap != null) { | ||
MDC.setContextMap(copyOfContextMap); | ||
} | ||
runnable.run(); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/hanglog/global/exception/AsyncExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package hanglog.global.exception; | ||
|
||
import java.lang.reflect.Method; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class AsyncExceptionHandler implements AsyncUncaughtExceptionHandler { | ||
|
||
@Override | ||
public void handleUncaughtException(final Throwable ex, final Method method, final Object... params) { | ||
log.error(ex.getMessage(), ex); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package hanglog.global.filter; | ||
|
||
public enum MdcKey { | ||
REQUEST_ID, | ||
REQUEST_METHOD, | ||
REQUEST_URI, | ||
REQUEST_TIME, | ||
REQUEST_IP; | ||
} |
45 changes: 45 additions & 0 deletions
45
backend/src/main/java/hanglog/global/filter/MdcLoggingFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package hanglog.global.filter; | ||
|
||
import static hanglog.global.filter.MdcKey.REQUEST_ID; | ||
import static hanglog.global.filter.MdcKey.REQUEST_IP; | ||
import static hanglog.global.filter.MdcKey.REQUEST_METHOD; | ||
import static hanglog.global.filter.MdcKey.REQUEST_TIME; | ||
import static hanglog.global.filter.MdcKey.REQUEST_URI; | ||
|
||
import jakarta.servlet.Filter; | ||
import jakarta.servlet.FilterChain; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.ServletRequest; | ||
import jakarta.servlet.ServletResponse; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
import org.slf4j.MDC; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Order(Ordered.HIGHEST_PRECEDENCE) | ||
public class MdcLoggingFilter implements Filter { | ||
|
||
@Override | ||
public void doFilter( | ||
final ServletRequest request, | ||
final ServletResponse response, | ||
final FilterChain chain | ||
) throws IOException, ServletException { | ||
setMdc((HttpServletRequest) request); | ||
chain.doFilter(request, response); | ||
MDC.clear(); | ||
} | ||
|
||
private void setMdc(final HttpServletRequest request) { | ||
MDC.put(REQUEST_ID.name(), UUID.randomUUID().toString()); | ||
MDC.put(REQUEST_METHOD.name(), request.getMethod()); | ||
MDC.put(REQUEST_URI.name(), request.getRequestURI()); | ||
MDC.put(REQUEST_TIME.name(), LocalDateTime.now().toString()); | ||
MDC.put(REQUEST_IP.name(), request.getRemoteAddr()); | ||
} | ||
} |
Oops, something went wrong.