SIENTIAPDE-1325
Refactor OPC class to remove unused opc_servers attribute and streamline initialization. Update OpcRepository to consolidate server name tags for metric emissions.
This commit is contained in:
@@ -49,7 +49,6 @@ class OPC(SientiaMonitoring):
|
|||||||
SientiaMonitoring.__init__(self, logger, notification_handler, metrics_controller)
|
SientiaMonitoring.__init__(self, logger, notification_handler, metrics_controller)
|
||||||
|
|
||||||
self.opc_repository: dict[str, OpcRepository] = {}
|
self.opc_repository: dict[str, OpcRepository] = {}
|
||||||
self.opc_servers = opc_servers
|
|
||||||
|
|
||||||
async def init_opc(self):
|
async def init_opc(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -161,6 +161,10 @@ class OpcRepository(SientiaMonitoring):
|
|||||||
- dict: Error information if connection failed
|
- dict: Error information if connection failed
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
tags = {
|
||||||
|
'pod_id': self.pod_id,
|
||||||
|
'server_name': self.server_name,
|
||||||
|
}
|
||||||
try:
|
try:
|
||||||
self.last_reconnection_time = datetime.now()
|
self.last_reconnection_time = datetime.now()
|
||||||
if self.client is None:
|
if self.client is None:
|
||||||
@@ -172,11 +176,7 @@ class OpcRepository(SientiaMonitoring):
|
|||||||
}
|
}
|
||||||
await self.client.connect()
|
await self.client.connect()
|
||||||
|
|
||||||
tags = {
|
|
||||||
'pod_id': self.pod_id,
|
|
||||||
'server_name': self.server_name,
|
|
||||||
}
|
|
||||||
|
|
||||||
await self.emit_metric(
|
await self.emit_metric(
|
||||||
metric_object=metrics.OPC_CONNECTION_STATUS,
|
metric_object=metrics.OPC_CONNECTION_STATUS,
|
||||||
method='set',
|
method='set',
|
||||||
@@ -260,7 +260,7 @@ class OpcRepository(SientiaMonitoring):
|
|||||||
method='set',
|
method='set',
|
||||||
tags={
|
tags={
|
||||||
'pod_id': self.pod_id,
|
'pod_id': self.pod_id,
|
||||||
'opc_server_id': self.id,
|
'server_name': self.server_name,
|
||||||
},
|
},
|
||||||
value=0,
|
value=0,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user