Loading src/kpi_manager/database/Kpi_DB.py +1 −3 Original line number Diff line number Diff line Loading @@ -70,8 +70,7 @@ class KpiDB: session.rollback() if "psycopg2.errors.UniqueViolation" in str(e): LOGGER.error(f"Unique key voilation: {row.__class__.__name__} table. {str(e)}") raise AlreadyExistsException(row.__class__.__name__, row, extra_details=["Unique key voilation: {:}".format(e)] ) raise AlreadyExistsException(row.__class__.__name__, row, extra_details=["Unique key voilation: {:}".format(e)] ) else: LOGGER.error(f"Failed to insert new row into {row.__class__.__name__} table. {str(e)}") raise OperationFailedException ("Deletion by column id", extra_details=["unable to delete row {:}".format(e)]) Loading @@ -90,7 +89,6 @@ class KpiDB: print("{:} ID not found, No matching row: {:}".format(model.__name__, id_to_search)) return None except Exception as e: session.rollback() LOGGER.debug(f"Failed to retrieve {model.__name__} ID. {str(e)}") raise OperationFailedException ("search by column id", extra_details=["unable to search row {:}".format(e)]) finally: Loading src/kpi_value_api/tests/messages.py +3 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,9 @@ from common.proto.kpi_value_api_pb2 import KpiValue, KpiValueList def create_kpi_value_list(): _create_kpi_value_list = KpiValueList() # To run this experiment sucessfully, already existing UUID in KPI DB in necessary. # because the UUID is used to get the descriptor form KPI DB. # To run this experiment sucessfully, add an existing UUID of a KPI Descriptor from the KPI DB. # This UUID is used to get the descriptor form the KPI DB. If the Kpi ID does not exists, # some part of the code won't execute. EXISTING_KPI_IDs = ["725ce3ad-ac67-4373-bd35-8cd9d6a86e09", str(uuid.uuid4()), str(uuid.uuid4())] Loading src/kpi_value_writer/service/MetricWriterToPrometheus.py +2 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ class MetricWriterToPrometheus: def create_and_expose_cooked_kpi(self, kpi_descriptor: KpiDescriptor, kpi_value: KpiValue): # merge both gRPC messages into single varible. cooked_kpi = self.merge_kpi_descriptor_and_kpi_value(kpi_descriptor, kpi_value) tags_to_exclude = {'kpi_description', 'kpi_sample_type', 'kpi_value'} # extracted values will be used as metric tag metric_tags = [tag for tag in cooked_kpi.keys() if tag not in tags_to_exclude] tags_to_exclude = {'kpi_description', 'kpi_sample_type', 'kpi_value'} metric_tags = [tag for tag in cooked_kpi.keys() if tag not in tags_to_exclude] # These values will be used as metric tags metric_name = cooked_kpi['kpi_sample_type'] try: if metric_name not in PROM_METRICS: # Only register the metric, when it doesn't exists Loading Loading
src/kpi_manager/database/Kpi_DB.py +1 −3 Original line number Diff line number Diff line Loading @@ -70,8 +70,7 @@ class KpiDB: session.rollback() if "psycopg2.errors.UniqueViolation" in str(e): LOGGER.error(f"Unique key voilation: {row.__class__.__name__} table. {str(e)}") raise AlreadyExistsException(row.__class__.__name__, row, extra_details=["Unique key voilation: {:}".format(e)] ) raise AlreadyExistsException(row.__class__.__name__, row, extra_details=["Unique key voilation: {:}".format(e)] ) else: LOGGER.error(f"Failed to insert new row into {row.__class__.__name__} table. {str(e)}") raise OperationFailedException ("Deletion by column id", extra_details=["unable to delete row {:}".format(e)]) Loading @@ -90,7 +89,6 @@ class KpiDB: print("{:} ID not found, No matching row: {:}".format(model.__name__, id_to_search)) return None except Exception as e: session.rollback() LOGGER.debug(f"Failed to retrieve {model.__name__} ID. {str(e)}") raise OperationFailedException ("search by column id", extra_details=["unable to search row {:}".format(e)]) finally: Loading
src/kpi_value_api/tests/messages.py +3 −2 Original line number Diff line number Diff line Loading @@ -18,8 +18,9 @@ from common.proto.kpi_value_api_pb2 import KpiValue, KpiValueList def create_kpi_value_list(): _create_kpi_value_list = KpiValueList() # To run this experiment sucessfully, already existing UUID in KPI DB in necessary. # because the UUID is used to get the descriptor form KPI DB. # To run this experiment sucessfully, add an existing UUID of a KPI Descriptor from the KPI DB. # This UUID is used to get the descriptor form the KPI DB. If the Kpi ID does not exists, # some part of the code won't execute. EXISTING_KPI_IDs = ["725ce3ad-ac67-4373-bd35-8cd9d6a86e09", str(uuid.uuid4()), str(uuid.uuid4())] Loading
src/kpi_value_writer/service/MetricWriterToPrometheus.py +2 −2 Original line number Diff line number Diff line Loading @@ -63,8 +63,8 @@ class MetricWriterToPrometheus: def create_and_expose_cooked_kpi(self, kpi_descriptor: KpiDescriptor, kpi_value: KpiValue): # merge both gRPC messages into single varible. cooked_kpi = self.merge_kpi_descriptor_and_kpi_value(kpi_descriptor, kpi_value) tags_to_exclude = {'kpi_description', 'kpi_sample_type', 'kpi_value'} # extracted values will be used as metric tag metric_tags = [tag for tag in cooked_kpi.keys() if tag not in tags_to_exclude] tags_to_exclude = {'kpi_description', 'kpi_sample_type', 'kpi_value'} metric_tags = [tag for tag in cooked_kpi.keys() if tag not in tags_to_exclude] # These values will be used as metric tags metric_name = cooked_kpi['kpi_sample_type'] try: if metric_name not in PROM_METRICS: # Only register the metric, when it doesn't exists Loading