From 032be28eb1cbc92de13d5352af71c6fcc22b7052 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 7 Nov 2025 08:58:11 -0300 Subject: [PATCH] SIENTIAPDE-1325 Refactor OpcManager to emit connection metrics after successful connection establishment - Moved the metric emission for OPC_CONNECTIONS_TOTAL to occur after a successful connection. - Removed redundant metric increment logic to streamline the connection process. --- ingestor/managers/opc_manager.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ingestor/managers/opc_manager.py b/ingestor/managers/opc_manager.py index ed16b87..451b719 100644 --- a/ingestor/managers/opc_manager.py +++ b/ingestor/managers/opc_manager.py @@ -197,15 +197,6 @@ class OpcManager(SientiaMonitoring): - OPC_CONNECTION_STATUS: Set to 1 on successful connection """ - await self.emit_metric( - metric_object=metrics.OPC_CONNECTIONS_TOTAL, - method='inc', - value=1, - tags={ - 'pod_id': self.pod_id, - 'server_name': self.name, - }, - ) try: self.client = Client(self.url, timeout=10, watchdog_intervall=3600000) assert self.client is not None # Informa ao mypy que client não é None @@ -230,6 +221,13 @@ class OpcManager(SientiaMonitoring): 'server_url': self.url, }, ) + await self.emit_metric( + metric_object=metrics.OPC_CONNECTIONS_TOTAL, + tags={ + 'pod_id': self.pod_id, + 'server_name': self.name, + } + ) self.logger.info(f'Connection to {self.name} successful.') except Exception: await self.disconnect()