Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;

import static org.logstash.ObjectMappers.LOG4J_JSON_MAPPER;

Expand All @@ -48,6 +49,17 @@ public void serialize(CustomLogEvent event, JsonGenerator generator, SerializerP
generator.writeObjectField("loggerName", event.getLoggerName());
generator.writeObjectField("timeMillis", event.getTimeMillis());
generator.writeObjectField("thread", event.getThreadName());

final String pipelineId = event.getContextData().getValue("pipeline.id");
if (Objects.nonNull(pipelineId) && !pipelineId.isEmpty()) {
Copy link
Contributor Author

@mashhurs mashhurs Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review note: for the safety I have placed a condition but it exists as we ThreadContext.put("pipeline.id", pipeline_id) and I have confirmed the places we accessing from org.apache.logging.log4j.ThreadContext, example java_pipeline.rb#start

Util::with_logging_thread_context("pipeline.id" => pipeline_id) do
        collect_stats
        collect_dlq_stats
        initialize_flow_metrics
      end

Note that, plugin IDs will be placed in the thread context in worker logics.

generator.writeStringField("pipeline.id", pipelineId);
}

final String pluginId = event.getContextData().getValue("plugin.id");
if (Objects.nonNull(pluginId) && !pluginId.isEmpty()) {
generator.writeStringField("plugin.id", pluginId);
}

generator.writeFieldName("logEvent");
generator.writeStartObject();

Expand Down