Skip to content

Commit

Permalink
fix-no-uuid in eventContext.getEventData().getMessageId() (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kortemik authored May 15, 2024
1 parent 89051d3 commit c0d3386
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/com/teragrep/aer_01/EventContextConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.UUID;
import java.util.function.Consumer;

final class EventContextConsumer implements AutoCloseable, Consumer<EventContext> {
Expand Down Expand Up @@ -96,9 +97,17 @@ private String getRealHostName() {

@Override
public void accept(EventContext eventContext) {

String eventUuid = eventContext.getEventData().getMessageId();

// FIXME proper handling of non-provided uuids
if (eventUuid == null) {
eventUuid = "aer_01="+UUID.randomUUID();
}

SDElement sdId = new SDElement("event_id@48577")
.addSDParam("hostname", realHostName)
.addSDParam("uuid", eventContext.getEventData().getMessageId())
.addSDParam("uuid", eventUuid)
.addSDParam("unixtime", Instant.now().toString())
.addSDParam("id_source", "source");
/*
Expand Down

0 comments on commit c0d3386

Please sign in to comment.