How to match log events in a distributed Vertx system

when executing logs in several vertx modules, this is a basic requirement so that we can match all the logs for a single query.

since vertx is asynchronous, which would be the best place to store logid, talkid, eventid.

any solution or patterns that we can implement?

+4
source share
2 answers

On a streaming system, the current context is held by the current thread, which is why MDC or any ThreadLocal will do.

On an actor-based system such as Vertx, your context is a message, so you need to add a correlation identifier for each message you send.

/ .

JsonObject, -

vertx.eventBus().send("someAddr", 
  new JsonObject().put("correlationId", "someId")
                  .put("payload", yourPayload));

DeliveryOption

//send
vertx.eventBus().send("someAddr", "someMsg", 
            new DeliveryOptions().addHeader("correlationId", "someId"));

//receive    
vertx.eventBus().consumer("someAddr", msg -> {
        String correlationId = msg.headers().get("correlationId");
        ...
    });

, Interceptor eventbus, Emanuel Idi Zipkin Vert.x, https://github.com/emmanuelidi/vertx-zipkin, .

+2

, Vertx, , ​​ SLF4J, Log4J, JUL .. , /var/logs/appName.

, , , Vertx, GrayLog / . , . , , . .

+1

Source: https://habr.com/ru/post/1015910/


All Articles