Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

프로메테우스, 그라파나 #15

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions d-gateway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {
//actuator
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.7.2'
// implementation 'org.springframework.cloud:spring-cloud-starter-bus-amqp:3.1.2'
implementation 'io.micrometer:micrometer-registry-prometheus:1.9.2'
}

//버전 알아서 찾아주는 애
Expand Down
2 changes: 1 addition & 1 deletion d-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ management:
endpoints:
web:
exposure:
include: refresh , health , beans , httptrace , busrefresh
include: refresh , health , beans , httptrace , busrefresh , info , metrics , prometheus


2 changes: 2 additions & 0 deletions d-order-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dependencies {
implementation 'org.springframework.kafka:spring-kafka:2.9.0' //카프카
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth:3.1.3' //sleuth
implementation 'org.springframework.cloud:spring-cloud-starter-zipkin:2.2.8.RELEASE' //zipkin
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.7.3' //spring cloud actuator
implementation 'io.micrometer:micrometer-registry-prometheus:1.9.2'


runtimeOnly 'com.h2database:h2' //runtime scope로 실행
Expand Down
9 changes: 8 additions & 1 deletion d-order-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ eureka:

logging:
level:
com.example.dorderservice : DEBUG
com.example.dorderservice : DEBUG

management:
endpoints:
web:
exposure:
include: info , metrics , prometheus

1 change: 1 addition & 0 deletions d-user-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j:2.1.3' //resilience4j
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth:3.1.3' //sleuth
implementation 'org.springframework.cloud:spring-cloud-starter-zipkin:2.2.8.RELEASE' //zipkin
implementation 'io.micrometer:micrometer-registry-prometheus:1.9.2'

implementation 'org.postgresql:postgresql:42.3.6'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.duserservice.config.EnvironmentDto;
import com.example.duserservice.service.UserService;
import com.example.duserservice.vo.*;
import io.micrometer.core.annotation.Timed;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
Expand All @@ -26,6 +27,7 @@ public class UserApiController {
private final Environment env;

//상태 체크 함수
@Timed(value = "users.status", longTask = true)
@GetMapping("/health_check")
public EnvironmentDto status() {

Expand All @@ -37,13 +39,19 @@ public EnvironmentDto status() {
.build();
}

@Timed(value = "users.welcome", longTask = true)
@GetMapping("/welcome")
public String welcome() {
return "welcome user-service";
}

@PostMapping("/users")
public ResponseEntity<ResponseUser> createUser(@RequestBody @Valid RequestUser requestUser) {

UserDto userDto = modelMapper.map(requestUser, UserDto.class);
userService.createUser(userDto);

ResponseUser responseUser = modelMapper.map(userDto , ResponseUser.class);
ResponseUser responseUser = modelMapper.map(userDto, ResponseUser.class);

return ResponseEntity.status(HttpStatus.CREATED).body(responseUser);
}
Expand All @@ -52,8 +60,8 @@ public ResponseEntity<ResponseUser> createUser(@RequestBody @Valid RequestUser r
public ResponseEntity findUsers() {
return ResponseEntity.status(HttpStatus.ACCEPTED).body(userService.findUserByAll());
}


//유저정보와 오더정보를 한번에 가져오기 (order : restTemplate 호출)
@GetMapping("/users/{userId}")
public ResponseEntity findUserByUserId(@PathVariable String userId) {
Expand Down
2 changes: 1 addition & 1 deletion d-user-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ management:
endpoints:
web:
exposure:
include: refresh , health , beans , busrefresh
include: refresh , health , beans , busrefresh , info , metrics , prometheus