stats api: startup resilience when stats are partially formed (#13645) (#13660)

(cherry picked from commit 4b430a5f69)
This commit is contained in:
Ry Biesemeyer 2022-01-24 07:39:31 -08:00 committed by GitHub
parent fe4827132b
commit 8d057881ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,8 @@ module LogStash; module Config;
p_stats = stats[pipeline_id]
# 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
next nil if p_stats.nil?
res = {
"id" => pipeline_id.to_s,
"hash" => pipeline.lir.unique_hash,
@ -33,8 +35,8 @@ module LogStash; module Config;
"events" => format_pipeline_events(p_stats[:events]),
"queue" => format_queue_stats(pipeline_id, metric_store),
"reloads" => {
"successes" => p_stats[:reloads][:successes].value,
"failures" => p_stats[:reloads][:failures].value
"successes" => (p_stats.dig(:reloads, :successes)&.value || 0),
"failures" => (p_stats.dig(:reloads, :failures)&.value || 0)
}
}
if extended_performance_collection