|
12 | 12 | require "logstash/filter_delegator"
|
13 | 13 | require "logstash/compiler"
|
14 | 14 |
|
| 15 | +java_import org.apache.logging.log4j.ThreadContext |
| 16 | + |
15 | 17 | module LogStash; class BasePipeline < AbstractPipeline
|
16 | 18 | include LogStash::Util::Loggable
|
17 | 19 |
|
@@ -172,7 +174,8 @@ def start
|
172 | 174 |
|
173 | 175 | @thread = Thread.new do
|
174 | 176 | begin
|
175 |
| - LogStash::Util.set_thread_name("pipeline.#{pipeline_id}") |
| 177 | + LogStash::Util.set_thread_name("[#{pipeline_id}]-manager") |
| 178 | + ThreadContext.put("pipeline.id", pipeline_id) |
176 | 179 | run
|
177 | 180 | @finished_run.make_true
|
178 | 181 | rescue => e
|
@@ -300,7 +303,8 @@ def start_workers
|
300 | 303 |
|
301 | 304 | pipeline_workers.times do |t|
|
302 | 305 | thread = Thread.new(batch_size, batch_delay, self) do |_b_size, _b_delay, _pipeline|
|
303 |
| - Util.set_thread_name("[#{pipeline_id}]>worker#{t}") |
| 306 | + LogStash::Util::set_thread_name("[#{pipeline_id}]>worker#{t}") |
| 307 | + ThreadContext.put("pipeline.id", pipeline_id) |
304 | 308 | _pipeline.worker_loop(_b_size, _b_delay)
|
305 | 309 | end
|
306 | 310 | @worker_threads << thread
|
@@ -430,6 +434,7 @@ def start_input(plugin)
|
430 | 434 |
|
431 | 435 | def inputworker(plugin)
|
432 | 436 | Util::set_thread_name("[#{pipeline_id}]<#{plugin.class.config_name}")
|
| 437 | + ThreadContext.put("pipeline.id", pipeline_id) |
433 | 438 | begin
|
434 | 439 | plugin.run(wrapped_write_client(plugin.id.to_sym))
|
435 | 440 | rescue => e
|
@@ -535,6 +540,8 @@ def start_flusher
|
535 | 540 | raise "Attempted to start flusher on a stopped pipeline!" if stopped?
|
536 | 541 |
|
537 | 542 | @flusher_thread = Thread.new do
|
| 543 | + LogStash::Util.set_thread_name("[#{pipeline_id}]-flusher-thread") |
| 544 | + ThreadContext.put("pipeline.id", pipeline_id) |
538 | 545 | while Stud.stoppable_sleep(5, 0.1) { stopped? }
|
539 | 546 | flush
|
540 | 547 | break if stopped?
|
|
0 commit comments