InnerMethodName used for accounting
This commit is contained in:
parent
4b75535a9d
commit
2fe7d3d4bc
|
@ -41,13 +41,16 @@ public class RequestAccounting extends RequestHandler {
|
||||||
|
|
||||||
|
|
||||||
String context = getContext(appContext);
|
String context = getContext(appContext);
|
||||||
|
|
||||||
String calledMethod = e.request().getRequestURI().substring(e.request().getContextPath().length());
|
if (InnerMethodName.instance.get()==null) {
|
||||||
if (calledMethod.isEmpty())
|
String calledMethod = e.request().getRequestURI().substring(e.request().getContextPath().length());
|
||||||
calledMethod = "/";
|
if (calledMethod.isEmpty())
|
||||||
calledMethod= e.request().getMethod()+" "+calledMethod;
|
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():
|
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
|
||||||
UNKNOWN;
|
UNKNOWN;
|
||||||
startCallThreadLocal.set(System.currentTimeMillis());
|
startCallThreadLocal.set(System.currentTimeMillis());
|
||||||
|
@ -63,7 +66,7 @@ public class RequestAccounting extends RequestHandler {
|
||||||
ApplicationContext appContext = e.context();
|
ApplicationContext appContext = e.context();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String context = getContext(appContext);
|
String context = getContext(appContext);
|
||||||
|
|
||||||
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
|
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)
|
if (appContext.container().configuration().mode()!=Mode.offline)
|
||||||
generateAccounting(caller,callerQualifier,callerIp==null?UNKNOWN:callerIp , success, context, appContext);
|
generateAccounting(caller,callerQualifier,callerIp==null?UNKNOWN:callerIp , success, context, appContext);
|
||||||
|
|
||||||
long durationInMillis = System.currentTimeMillis()-startCallThreadLocal.get();
|
long durationInMillis = System.currentTimeMillis()-startCallThreadLocal.get();
|
||||||
|
|
||||||
Metrics.globalRegistry.timer("http.requests", "response",Integer.toString(e.response().getStatus())
|
Metrics.globalRegistry.timer("http.requests", "response",Integer.toString(e.response().getStatus())
|
||||||
, "context", context, "result", success?"SUCCEDED":"FAILED", "caller-ip", callerIp,
|
, "context", context, "result", success?"SUCCEDED":"FAILED", "caller-ip", callerIp,
|
||||||
"caller-username", caller, "service-class", appContext.configuration().serviceClass(), "service-name", appContext.configuration().name(),
|
"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",
|
log.info("REQUEST SERVED ON {}:{}({}) CALLED FROM {}@{} IN SCOPE {} {}(CODE {}) IN {} millis",
|
||||||
appContext.configuration().name(),appContext.configuration().serviceClass(), InnerMethodName.instance.get(),
|
appContext.configuration().name(),appContext.configuration().serviceClass(), InnerMethodName.instance.get(),
|
||||||
caller, callerIp, context, success?"SUCCEDED":"FAILED", e.response().getStatus(),durationInMillis);
|
caller, callerIp, context, success?"SUCCEDED":"FAILED", e.response().getStatus(),durationInMillis);
|
||||||
startCallThreadLocal.remove();
|
|
||||||
InnerMethodName.instance.reset();
|
|
||||||
|
|
||||||
|
|
||||||
}catch (Exception e1) {
|
}catch (Exception e1) {
|
||||||
log.error("error on accounting",e);
|
log.error("error on accounting",e);
|
||||||
throw e1;
|
throw e1;
|
||||||
|
} finally {
|
||||||
|
startCallThreadLocal.remove();
|
||||||
|
InnerMethodName.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -130,7 +135,7 @@ public class RequestAccounting extends RequestHandler {
|
||||||
context = SecretManagerProvider.instance.get().getContext();
|
context = SecretManagerProvider.instance.get().getContext();
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
return getName();
|
||||||
|
|
Loading…
Reference in New Issue