From f2e21b1cc5c89e5075267f4c24e985a476f1cce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Haracewiat?= Date: Mon, 13 Apr 2026 13:16:43 +0200 Subject: [PATCH] feat: decouple resources overview from chorus --- src/Command/Metrics/MetricsCommandBase.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Command/Metrics/MetricsCommandBase.php b/src/Command/Metrics/MetricsCommandBase.php index fe1402da5..2a1e1d661 100644 --- a/src/Command/Metrics/MetricsCommandBase.php +++ b/src/Command/Metrics/MetricsCommandBase.php @@ -75,15 +75,29 @@ protected function addMetricsOptions() * Returns the resources overview URL for the selected environment. * * @param Environment $environment - * @return string|false The link data or false on failure + * @return string|false The resources overview URL, or false if not available * @throws \GuzzleHttp\Exception\GuzzleException if there is an error in fetching observability metadata */ private function getResourcesOverviewUrl(Environment $environment) { - if (!$environment->hasLink('#observability-pipeline')) { + $entrypointUrl = rtrim($environment->getUri(), '/') . '/observability/'; + + $client = $this->api()->getHttpClient(); + $request = $client->createRequest('GET', $entrypointUrl); + + try { + $response = $client->send($request); + } catch (BadResponseException $e) { return false; } - return rtrim($environment->getLink('#observability-pipeline'), '/') . '/resources/overview'; + + $data = json_decode($response->getBody()->__toString(), true); + + if (empty($data['_links']['resources_overview']['href'])) { + return false; + } + + return $data['_links']['resources_overview']['href']; } /**