Revision 56601
Added by Katerina Iatropoulou almost 5 years ago
ExceptionController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.search.web.api; |
2 | 2 |
|
3 | 3 |
|
4 |
import io.micrometer.prometheus.PrometheusMeterRegistry; |
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
4 | 6 |
import org.springframework.http.HttpStatus; |
5 | 7 |
import org.springframework.http.ResponseEntity; |
6 | 8 |
import org.springframework.web.bind.annotation.ControllerAdvice; |
... | ... | |
11 | 13 |
@EnableWebMvc |
12 | 14 |
@ControllerAdvice(value = "eu.dnetlib.data.search.web.api", assignableTypes = SearchRequestController.class) |
13 | 15 |
public class ExceptionController extends ResponseEntityExceptionHandler{ |
16 |
|
|
17 |
@Autowired |
|
18 |
PrometheusMeterRegistry registry; |
|
19 |
|
|
14 | 20 |
@ExceptionHandler(Exception.class) |
15 | 21 |
public ResponseEntity<Error> invalidInput(Exception ex) { |
16 | 22 |
Error response = new Error(); |
... | ... | |
19 | 25 |
response.setMessage("500 - Internal server error."); |
20 | 26 |
response.setException(ex.getMessage()); |
21 | 27 |
|
28 |
|
|
29 |
registry.counter("http.status.500", "500", "uri").increment(); |
|
22 | 30 |
return new ResponseEntity<Error>(response, HttpStatus.CONFLICT); |
23 | 31 |
} |
24 | 32 |
} |
Also available in: Unified diff
Adding metrics with micrometer