From 9d7abda6a964296581577a1700cf9ecb43047f74 Mon Sep 17 00:00:00 2001 From: Deeka Wong Date: Thu, 9 Nov 2023 16:12:15 +0800 Subject: [PATCH] Adds `metric.enable_command_metric` switch (#6272) --- publish/metric.php | 1 + src/Listener/OnBeforeHandle.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/publish/metric.php b/publish/metric.php index 34d293f..d95ba53 100644 --- a/publish/metric.php +++ b/publish/metric.php @@ -18,6 +18,7 @@ 'default' => env('METRIC_DRIVER', 'prometheus'), 'use_standalone_process' => env('METRIC_USE_STANDALONE_PROCESS', true), 'enable_default_metric' => env('METRIC_ENABLE_DEFAULT_METRIC', true), + 'enable_command_metric' => env('METRIC_ENABLE_COMMAND_METRIC', true), 'default_metric_interval' => env('DEFAULT_METRIC_INTERVAL', 5), 'metric' => [ 'prometheus' => [ diff --git a/src/Listener/OnBeforeHandle.php b/src/Listener/OnBeforeHandle.php index 0fa0c32..868c540 100644 --- a/src/Listener/OnBeforeHandle.php +++ b/src/Listener/OnBeforeHandle.php @@ -63,6 +63,10 @@ public function process(object $event): void return; } + if (! $this->config->get('metric.enable_command_metric', true)) { + return; + } + MetricFactoryPicker::$isCommand = true; if ($this->config->get('metric.use_standalone_process', true)) {