|
|
|
@ -41,13 +41,16 @@ 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;
|
|
|
|
|
|
|
|
|
|
InnerMethodName.instance.set(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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
|
|
|
|
|
UNKNOWN;
|
|
|
|
|
startCallThreadLocal.set(System.currentTimeMillis());
|
|
|
|
@ -63,7 +66,7 @@ public class RequestAccounting extends RequestHandler {
|
|
|
|
|
ApplicationContext appContext = e.context();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String context = getContext(appContext);
|
|
|
|
|
|
|
|
|
|
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
|
|
|
|
@ -78,9 +81,9 @@ public class RequestAccounting extends RequestHandler {
|
|
|
|
|
|
|
|
|
|
if (appContext.container().configuration().mode()!=Mode.offline)
|
|
|
|
|
generateAccounting(caller,callerQualifier,callerIp==null?UNKNOWN:callerIp , success, context, appContext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long durationInMillis = System.currentTimeMillis()-startCallThreadLocal.get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Metrics.globalRegistry.timer("http.requests", "response",Integer.toString(e.response().getStatus())
|
|
|
|
|
, "context", context, "result", success?"SUCCEDED":"FAILED", "caller-ip", callerIp,
|
|
|
|
|
"caller-username", caller, "service-class", appContext.configuration().serviceClass(), "service-name", appContext.configuration().name(),
|
|
|
|
@ -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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -130,7 +135,7 @@ public class RequestAccounting extends RequestHandler {
|
|
|
|
|
context = SecretManagerProvider.instance.get().getContext();
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return getName();
|
|
|
|
|