InnerMethodName used for accounting

This commit is contained in:
Lucio Lelii 2022-07-20 17:31:20 +02:00
parent 4b75535a9d
commit 2fe7d3d4bc
1 changed files with 18 additions and 13 deletions

View File

@ -42,12 +42,15 @@ public class RequestAccounting extends RequestHandler {
String context = getContext(appContext);
String calledMethod = e.request().getRequestURI().substring(e.request().getContextPath().length());
if (calledMethod.isEmpty())
calledMethod = "/";
calledMethod= e.request().getMethod()+" "+calledMethod;
if (InnerMethodName.instance.get()==null) {
String calledMethod = e.request().getRequestURI().substring(e.request().getContextPath().length());
if (calledMethod.isEmpty())
calledMethod = "/";
calledMethod= e.request().getMethod()+" "+calledMethod;
InnerMethodName.instance.set(calledMethod);
}
InnerMethodName.instance.set(calledMethod);
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
UNKNOWN;
startCallThreadLocal.set(System.currentTimeMillis());
@ -89,12 +92,14 @@ public class RequestAccounting extends RequestHandler {
log.info("REQUEST SERVED ON {}:{}({}) CALLED FROM {}@{} IN SCOPE {} {}(CODE {}) IN {} millis",
appContext.configuration().name(),appContext.configuration().serviceClass(), InnerMethodName.instance.get(),
caller, callerIp, context, success?"SUCCEDED":"FAILED", e.response().getStatus(),durationInMillis);
startCallThreadLocal.remove();
InnerMethodName.instance.reset();
}catch (Exception e1) {
log.error("error on accounting",e);
throw e1;
} finally {
startCallThreadLocal.remove();
InnerMethodName.instance.reset();
}
}