From 47d04d06b2d2f47e4347d1997de77359fa91b047 Mon Sep 17 00:00:00 2001 From: Mashhur <99575341+mashhurs@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:30:49 -0800 Subject: [PATCH] Initialize flow metrics if pipeline metric.collect params is enabled. (#16881) --- .../main/java/org/logstash/execution/AbstractPipelineExt.java | 1 + 1 file changed, 1 insertion(+) diff --git a/logstash-core/src/main/java/org/logstash/execution/AbstractPipelineExt.java b/logstash-core/src/main/java/org/logstash/execution/AbstractPipelineExt.java index c169ee05380..a0c4488b779 100644 --- a/logstash-core/src/main/java/org/logstash/execution/AbstractPipelineExt.java +++ b/logstash-core/src/main/java/org/logstash/execution/AbstractPipelineExt.java @@ -558,6 +558,7 @@ public final IRubyObject collectStats(final ThreadContext context) throws IOExce @JRubyMethod(name = "initialize_flow_metrics") public final IRubyObject initializeFlowMetrics(final ThreadContext context) { if (metric.collector(context).isNil()) { return context.nil; } + if (!getSetting(context, "metric.collect").isTrue()) { return context.nil; } final UptimeMetric uptimeMetric = initOrGetUptimeMetric(context, buildNamespace(), UPTIME_IN_MILLIS_KEY); final Metric uptimeInPreciseMillis = uptimeMetric.withUnitsPrecise(MILLISECONDS);