mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
When a pipeline isn't fully initialized, we run the risk of attempting to
format pipeline info that isn't yet fully-shaped. By using safe-fallback
methods like `Hash#dig` and conditional-chaining, we can avoid the spurious
`NoMethodError` caused by sending `[]` to nil.
(cherry picked from commit e9455ca81e
)
This commit is contained in:
parent
f0fa13d188
commit
5d0ad6ea38
1 changed files with 2 additions and 2 deletions
|
@ -21,9 +21,9 @@ module LogStash; module Config;
|
|||
# It is important that we iterate via the agent's pipelines vs. the
|
||||
# metrics pipelines. This prevents race conditions as pipeline stats may be
|
||||
# populated before the agent has it in its own pipelines state
|
||||
stats = metric_store.get_with_path("/stats/pipelines")[:stats][:pipelines]
|
||||
stats = metric_store.get_with_path("/stats/pipelines").dig(:stats, :pipelines) || {}
|
||||
agent.running_pipelines.map do |pipeline_id, pipeline|
|
||||
p_stats = stats[pipeline_id]
|
||||
p_stats = stats.fetch(pipeline_id) { Hash.new }
|
||||
# Don't record stats for system pipelines
|
||||
next nil if pipeline.system?
|
||||
# Don't emit stats for pipelines that have not yet registered any metrics
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue