🍃 Spring

    Spring Actuator + Prometheus + Grafana

    이전에 Actuator로 무식하게 데이터를 확인했다면 이제는 위의 두 서버를 받아서 로그를 시각화해서 보자! 아래는 윈도우 기준이지만 크게 상관없다. 연결 샘플 프로젝트는 아래 깃헙을 참조. GitHub - stir084/spring-grafana-prometheus: grafana-prometheus sample grafana-prometheus sample. Contribute to stir084/spring-grafana-prometheus development by creating an account on GitHub. github.com 설치 https://grafana.com/grafana/download?platform=windows https://prometheus.io/download/ ..

    Spring Actuator와 Thread(+@Scheduled)

    이번에 Spring Actuator를 써보면서 Thread 측면에서 잘못 알고 있었던 점을 바로 잡고 배웠던 점을 공유하려고 한다. Actuator 설정 implementation 'org.springframework.boot:spring-boot-starter-actuator' 우선 스프링부트에서 위와 같이 의존성을 추가해 준다. http://localhost:8080/actuator 그리고 스프링부트를 실행시키고 위의 링크를 들어가 보자 /actuator/로 접속 시 오류가 발생하니까 정확히 /actuator로 들어가자. 그럼 위와 같은 화면이 나타난다. 아직은 보이는 정보가 그렇게 많지 않을 것이다. management.endpoints.web.exposure.include=* # 모든 endpoi..

    @Transactional을 테스트에 써야할까?

    Don’t Use @Transactional in Tests How to not ruin your Spring Boot application test suite medium.com 예전에 이 글 보고 쓰지말자라고만 생각했다. @Transactional을 써서 얻는 부작용이 꽤 많아 보였기 때문이다. 위 영상을 보면 @Transactional을 테스트에 쓰는 것이 단점에 비하면 얻는 장점이 많다고 한다. 영상에 나온 단점을 다 이해할 순 없지만 개인적으로 느꼈던 단점 중 하나는 트랜잭션이 비즈니스 로직에 적혀있지 않아도 테스트에 있는 @Transacitonal이 전파된다라는 특징 때문에 운영 서비스에 크리티컬 이슈를 발생시킬 수도 있다라는 생각을 했다. 영상에선 그 외 단점도 설명도 하고 있는데 JPA를 ..

    @JsonProperty 사용법에 대한 모든 것

    필드명이 다를 때 치환 용도 @GetMapping("/changeCamelCase1") public String changeCamelCase1(@RequestBody Student1 student) { System.out.println(student.myAge + "--" + student.myName); return "ok"; } @GetMapping("/changeCamelCase2") public String changeCamelCase2(@RequestBody Student2 student) { System.out.println(student.myAge + "--" + student.myName); return "ok"; } @Data public static class Student1 { @Js..