SIENTIAPDE-1325
Refactor OPC metrics in metrics.py and opc_repository.py - Replaced existing OPC connection metrics with new metrics for total connections and failed connections. - Updated the OPC connection status metric to include server URL and adjusted corresponding metric emissions in opc_repository.py.
This commit is contained in:
@@ -114,22 +114,20 @@ PREDICTION_OPC_WRITING_RESPONSE_TIME_MONITOR = Histogram(
|
|||||||
buckets=[0.01, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0],
|
buckets=[0.01, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
OPC_CONNECTIONS_TOTAL = Counter(
|
||||||
|
'opc_connections_initiated_total',
|
||||||
|
'Total connection attempts to OPC servers',
|
||||||
|
['pod_id', 'server_name'],
|
||||||
|
)
|
||||||
|
OPC_CONNECTIONS_FAILED = Counter(
|
||||||
|
'opc_connections_failed_total',
|
||||||
|
'Total failed connection attempts to OPC servers',
|
||||||
|
['pod_id', 'server_name'],
|
||||||
|
)
|
||||||
OPC_CONNECTION_STATUS = Gauge(
|
OPC_CONNECTION_STATUS = Gauge(
|
||||||
'laborious_opc_connection_status',
|
'opc_connection_status',
|
||||||
'Connection status with the OPC server (1=connected, 0=disconnected)',
|
'Connection status with the OPC server (1=connected, 0=disconnected)',
|
||||||
['pod_id', 'opc_server_id'],
|
['pod_id', 'server_name', 'server_url'],
|
||||||
)
|
|
||||||
|
|
||||||
OPC_CONNECTION_COUNT = Counter(
|
|
||||||
'laborious_opc_connection_count',
|
|
||||||
'Number of connections to the OPC server',
|
|
||||||
['pod_id', 'opc_server_id'],
|
|
||||||
)
|
|
||||||
|
|
||||||
OPC_CONNECTION_ERROR_COUNT = Counter(
|
|
||||||
'laborious_opc_connection_error_count',
|
|
||||||
'Number of errors connecting to the OPC server',
|
|
||||||
['pod_id', 'opc_server_id'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# ================== Model metrics ==================
|
# ================== Model metrics ==================
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class OpcRepository(SientiaMonitoring):
|
|||||||
value=1,
|
value=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
await self.emit_metric(metrics.OPC_CONNECTION_COUNT, tags)
|
await self.emit_metric(metrics.OPC_CONNECTIONS_TOTAL, tags)
|
||||||
|
|
||||||
return True, {}
|
return True, {}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -191,7 +191,7 @@ class OpcRepository(SientiaMonitoring):
|
|||||||
trace = traceback.format_exc()
|
trace = traceback.format_exc()
|
||||||
self.logger.custom_error(trace, self.metadata)
|
self.logger.custom_error(trace, self.metadata)
|
||||||
|
|
||||||
await self.emit_metric(metrics.OPC_CONNECTION_ERROR_COUNT, tags)
|
await self.emit_metric(metrics.OPC_CONNECTIONS_FAILED, tags)
|
||||||
|
|
||||||
return False, {
|
return False, {
|
||||||
'notification_id': f'OPC_CONNECTION_ERROR_{self.id}',
|
'notification_id': f'OPC_CONNECTION_ERROR_{self.id}',
|
||||||
|
|||||||
Reference in New Issue
Block a user