Search in sources :

Example 1 with ActionDocument

use of core.log.domain.ActionDocument in project core-ng-project by neowu.

the class ActionService method action.

private ActionDocument action(ActionLogMessage message) {
    ActionDocument actionLog = new ActionDocument();
    actionLog.date = message.date;
    actionLog.app = message.app;
    actionLog.serverIP = message.serverIP;
    actionLog.id = message.id;
    actionLog.result = message.result;
    actionLog.refId = message.refId;
    actionLog.action = message.action;
    actionLog.errorCode = message.errorCode;
    actionLog.errorMessage = message.errorMessage;
    actionLog.elapsed = message.elapsed;
    actionLog.cpuTime = message.cpuTime;
    actionLog.context = message.context;
    actionLog.stats = message.stats;
    actionLog.performanceStats = message.performanceStats;
    return actionLog;
}
Also used : ActionDocument(core.log.domain.ActionDocument)

Example 2 with ActionDocument

use of core.log.domain.ActionDocument in project core-ng-project by neowu.

the class ActionServiceTest method bulkIndex.

@Test
void bulkIndex() {
    List<ActionLogMessage> messages = Lists.newArrayList();
    for (int i = 0; i < 6; i++) {
        ActionLogMessage message = message("bulk-" + i, "TRACE");
        message.traceLog = "trace";
        messages.add(message);
    }
    LocalDate now = LocalDate.of(2016, Month.JANUARY, 15);
    actionService.index(messages, now);
    ActionDocument action = actionDocument(now, messages.get(0).id);
    assertThat(action.result).isEqualTo("TRACE");
}
Also used : ActionLogMessage(core.framework.log.message.ActionLogMessage) LocalDate(java.time.LocalDate) ActionDocument(core.log.domain.ActionDocument) Test(org.junit.jupiter.api.Test) IntegrationTest(core.log.IntegrationTest)

Example 3 with ActionDocument

use of core.log.domain.ActionDocument in project core-ng-project by neowu.

the class DiagramService method getActionById.

private ActionDocument getActionById(String id) {
    var request = new SearchRequest();
    request.index = "action-*";
    request.query = new Query.Builder().ids(ids(List.of(id))).build();
    List<ActionDocument> documents = actionType.search(request).hits;
    if (documents.isEmpty())
        throw new NotFoundException("action not found, id=" + id);
    return documents.get(0);
}
Also used : SearchRequest(core.framework.search.SearchRequest) Query(co.elastic.clients.elasticsearch._types.query_dsl.Query) NotFoundException(core.framework.web.exception.NotFoundException) ActionDocument(core.log.domain.ActionDocument)

Example 4 with ActionDocument

use of core.log.domain.ActionDocument in project core-ng-project by neowu.

the class DiagramService method action.

public String action(String actionId) {
    var diagram = new ActionDiagram();
    ActionDocument action = getActionById(actionId);
    boolean isRootAction = action.correlationIds == null;
    if (isRootAction)
        diagram.add(action);
    List<String> correlationIds = isRootAction ? List.of(actionId) : action.correlationIds;
    List<ActionDocument> actions = findActionByCorrelationIds(correlationIds);
    actions.forEach(diagram::add);
    if (!isRootAction) {
        // if not root action, then correlationId will be id of root action
        List<ActionDocument> rootActions = findActionByIds(correlationIds);
        for (ActionDocument rootAction : rootActions) {
            diagram.add(rootAction);
        }
    }
    return diagram.dot();
}
Also used : ActionDocument(core.log.domain.ActionDocument)

Example 5 with ActionDocument

use of core.log.domain.ActionDocument in project core-ng-project by neowu.

the class ActionDiagram method apps.

private Set<String> apps() {
    Set<String> apps = new HashSet<>();
    for (Map.Entry<Key, List<ActionDocument>> entry : actions.entrySet()) {
        Key key = entry.getKey();
        apps.add(key.app);
        if ((key.action.startsWith("api:") || key.action.startsWith("topic:")) && !key.action.contains(":task:")) {
            for (ActionDocument action : entry.getValue()) {
                apps.addAll(clients(action));
            }
        }
    }
    return apps;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet) ActionDocument(core.log.domain.ActionDocument)

Aggregations

ActionDocument (core.log.domain.ActionDocument)10 ActionLogMessage (core.framework.log.message.ActionLogMessage)3 IntegrationTest (core.log.IntegrationTest)2 TraceDocument (core.log.domain.TraceDocument)2 LocalDate (java.time.LocalDate)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Test (org.junit.jupiter.api.Test)2 Query (co.elastic.clients.elasticsearch._types.query_dsl.Query)1 CodeBuilder (core.framework.internal.asm.CodeBuilder)1 PerformanceStatMessage (core.framework.log.message.PerformanceStatMessage)1 SearchRequest (core.framework.search.SearchRequest)1 NotFoundException (core.framework.web.exception.NotFoundException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1