我正在使用以下方法调用每个api。
有一个如下所示的控件,我正在调用“ / my”以获取api的响应
@GetMapping(value = {"/my"}, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<String> my(HttpServletResponse httpServletResponse,HttpServletRequest httpServletRequest)
ResponseEntity<String> iapiResponse = apiServices.getJsonResponse(iapi,
I_API, HttpMethod.GET,
new HttpEntity<String>(Utilities.getHeaders(httpServletRequest)),
httpServletRequest);
return iapiResponse
内部呼叫
private ResponseEntity<String> getJsonResponse(String url,
String apiName,
HttpMethod httpMethod,
HttpEntity<String> httpEntity,
HttpServletRequest httpServletRequest)
{
httpServletRequest.setAttribute("api", apiName);
ResponseEntity<String> itemResponseEntity = null;
try {
itemResponseEntity = restTemplate.exchange(url, httpMethod, httpEntity, String.class);
} catch (Exception e) {
throw new LocalHttpClientErrorException(e.getLocalizedMessage());
}
return itemResponseEntity;
}
在普罗米修斯,度量标准为
http_server_requests_seconds_sum {exception =“ LocalHttpClientErrorException”,method =“ GET”,outcome =“ SERVER_ERROR”,status =“ 502”,uri =“ / my”,} 0.740494179
我想修改它并添加apiName,这样我就可以知道哪个api导致了此错误
http_server_requests_seconds_count {exception =“ LocalHttpClientErrorException”,method =“ GET”,outcome =“ SERVER_ERROR”,status =“ 502”,uri =“ / my”,api =“ iapi”} 18.0
我该如何实现?