added caller information

master
Lucio Lelii 2 years ago
parent 80f5de688a
commit 6f999bcedc

@ -28,7 +28,7 @@ public class RequestAccounting extends RequestHandler {
private static ThreadLocal<Long> startCallThreadLocal = new ThreadLocal<Long>();
private static final String UNKNOWN = "Unknown";
@Override
public String getName() {
@ -42,15 +42,14 @@ public class RequestAccounting extends RequestHandler {
String context = getContext(appContext);
String calledMethod = e.request().getHeader(Constants.called_method_header);
if (calledMethod==null){
calledMethod = e.request().getRequestURI().substring(e.request().getContextPath().length());
if (calledMethod.isEmpty())
calledMethod = "/";
calledMethod= e.request().getMethod()+" "+calledMethod;
}
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 = "Unknown";
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
UNKNOWN;
startCallThreadLocal.set(System.currentTimeMillis());
log.info("REQUEST START ON {}:{}({}) CALLED FROM {}@{} IN SCOPE {} ",
@ -67,8 +66,9 @@ public class RequestAccounting extends RequestHandler {
String context = getContext(appContext);
String caller = "Unknown";
String callerQualifier = "UNKNOWN";
String caller = SecretManagerProvider.instance.get()!=null ? SecretManagerProvider.instance.get().getOwner().getId():
UNKNOWN;
String callerQualifier = UNKNOWN;
//retieves caller Ip when there is a proxy
String callerIp = e.request().getHeader("x-forwarded-for");
if(callerIp==null)
@ -77,7 +77,7 @@ public class RequestAccounting extends RequestHandler {
boolean success = e.response().getStatus()<400;
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();

Loading…
Cancel
Save