use of core.framework.impl.log.ActionLog in project core-ng-project by neowu.
the class HTTPServerHandler method handle.
private void handle(String path, HttpServerExchange exchange) {
ActionLog actionLog = logManager.begin("=== http transaction begin ===");
RequestImpl request = new RequestImpl(exchange, requestBeanMapper);
try {
// initialize webContext at beginning, the customerErrorHandler in errorHandler may use it if any exception
webContext.initialize(request);
requestParser.parse(request, exchange, actionLog);
request.session = sessionManager.load(request);
HeaderMap headers = exchange.getRequestHeaders();
String client = headers.getFirst(HTTPServerHandler.HEADER_CLIENT);
if (client != null)
actionLog.context("client", client);
actionLog.refId(headers.getFirst(HTTPServerHandler.HEADER_REF_ID));
ControllerHolder controller = route.get(path, request.method(), request.pathParams, actionLog);
actionLog.action(controller.action);
actionLog.context("controller", controller.controllerInfo);
logger.debug("controllerClass={}", controller.controller.getClass().getCanonicalName());
// trigger trace after action is determined due to trace log use action as part of path, is there better way?
if ("true".equals(headers.getFirst(HEADER_TRACE))) {
actionLog.trace = true;
}
Response response = new InvocationImpl(controller, interceptors, request, webContext).proceed();
sessionManager.save(request, response);
responseHandler.render((ResponseImpl) response, exchange, actionLog);
} catch (Throwable e) {
logManager.logError(e);
errorHandler.handleError(e, exchange, request, actionLog);
} finally {
webContext.cleanup();
logManager.end("=== http transaction end ===");
}
}
use of core.framework.impl.log.ActionLog in project core-ng-project by neowu.
the class KafkaMessagePublisher method linkContext.
private void linkContext(Headers headers) {
ActionLog actionLog = logManager.currentActionLog();
if (actionLog == null)
return;
headers.add(KafkaHeaders.HEADER_REF_ID, Strings.bytes(actionLog.refId()));
if (actionLog.trace)
headers.add(KafkaHeaders.HEADER_TRACE, Strings.bytes("true"));
}
use of core.framework.impl.log.ActionLog in project core-ng-project by neowu.
the class ExecutorImpl method submit.
@Override
public <T> Future<T> submit(String action, Callable<T> task) {
ActionLog parentActionLog = logManager.currentActionLog();
String taskAction = parentActionLog.action + ":" + action;
String refId = parentActionLog.refId();
boolean trace = parentActionLog.trace;
return executor.submit(() -> {
try {
ActionLog actionLog = logManager.begin("=== task execution begin ===");
actionLog.refId(refId);
actionLog.action(taskAction);
if (trace) {
actionLog.trace = true;
}
return task.call();
} catch (Throwable e) {
logManager.logError(e);
throw e;
} finally {
logManager.end("=== task execution end ===");
}
});
}
use of core.framework.impl.log.ActionLog in project core-ng-project by neowu.
the class ActionLogContext method get.
public static Optional<String> get(String key) {
LogManager logManager = logManager();
ActionLog actionLog = logManager.currentActionLog();
if (actionLog == null)
return Optional.empty();
return actionLog.context(key);
}
use of core.framework.impl.log.ActionLog in project core-ng-project by neowu.
the class ActionLogContext method stat.
// used to collect business metrics, and can be aggregated by Elasticsearch/Kibana
public static void stat(String key, Number value) {
LogManager logManager = logManager();
ActionLog actionLog = logManager.currentActionLog();
if (actionLog != null) {
actionLog.stat(key, value);
}
}
Aggregations