Skip to content

Commit

Permalink
Merge pull request #38 from urdego/feat(#37)
Browse files Browse the repository at this point in the history
feat(#37): prometheus 엔드포인트 예외 반환 처리
  • Loading branch information
j-ra1n authored Mar 4, 2025
2 parents e5e4f82 + b9690f4 commit b8e1a0f
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import feign.FeignException;
import io.urdego.urdego_content_service.common.exception.content.UserContentException;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
Expand All @@ -11,7 +12,6 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


import java.util.stream.Collectors;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
Expand Down Expand Up @@ -85,5 +85,21 @@ public ResponseEntity<ErrorResponse> handleFeignException(FeignException e) {

return ResponseEntity.badRequest().body(error);
}

@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(Exception e, HttpServletRequest request) {

String requestUri = request.getRequestURI();

// Prometheus 요청 예외 처리 제외
if (requestUri.startsWith("/actuator/prometheus")) {
return ResponseEntity.status(HttpStatus.OK).build();
}

ErrorResponse error =
ErrorResponse.from(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Internal Server Error", e.getMessage());

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
}
}

0 comments on commit b8e1a0f

Please sign in to comment.