SIENTIAPDE-1325
Refactor OpcManager to emit connection metrics immediately after connection attempt - Moved the emission of OPC_CONNECTIONS_TOTAL metric to occur right after the connection attempt, ensuring accurate tracking of connection status. - Removed redundant metric emission logic that was previously placed after a successful connection.
This commit is contained in:
@@ -197,6 +197,13 @@ class OpcManager(SientiaMonitoring):
|
|||||||
- OPC_CONNECTION_STATUS: Set to 1 on successful connection
|
- OPC_CONNECTION_STATUS: Set to 1 on successful connection
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
await self.emit_metric(
|
||||||
|
metric_object=metrics.OPC_CONNECTIONS_TOTAL,
|
||||||
|
tags={
|
||||||
|
'pod_id': self.pod_id,
|
||||||
|
'server_name': self.name,
|
||||||
|
}
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
self.client = Client(self.url, timeout=10, watchdog_intervall=3600000)
|
self.client = Client(self.url, timeout=10, watchdog_intervall=3600000)
|
||||||
assert self.client is not None # Informa ao mypy que client não é None
|
assert self.client is not None # Informa ao mypy que client não é None
|
||||||
@@ -221,13 +228,6 @@ class OpcManager(SientiaMonitoring):
|
|||||||
'server_url': self.url,
|
'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.')
|
self.logger.info(f'Connection to {self.name} successful.')
|
||||||
except Exception:
|
except Exception:
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
|
|||||||
Reference in New Issue
Block a user