From 7523cf82b0803edfd73d5004188a6455768bea95 Mon Sep 17 00:00:00 2001 From: Francesco Murdaca Date: Tue, 26 Jan 2021 07:26:39 +0100 Subject: [PATCH] Standardize metrics for revision check (#434) Signed-off-by: Francesco Murdaca --- consumer.py | 4 +++- .../investigate_advise_justification.py | 7 +++---- thoth/investigator/configuration.py | 2 ++ thoth/investigator/metrics.py | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/consumer.py b/consumer.py index 4ca9b995..381fd10e 100644 --- a/consumer.py +++ b/consumer.py @@ -92,7 +92,9 @@ openshift = OpenShift() graph = GraphDatabase() -schema_revision_metric.labels("investigator", graph.get_script_alembic_version_head()).set(1) +schema_revision_metric.labels( + "investigator", graph.get_script_alembic_version_head(), Configuration.DEPLOYMENT_NAME +).set(1) graph.connect() diff --git a/thoth/investigator/advise_justification/investigate_advise_justification.py b/thoth/investigator/advise_justification/investigate_advise_justification.py index 623bed46..cd170ec3 100644 --- a/thoth/investigator/advise_justification/investigate_advise_justification.py +++ b/thoth/investigator/advise_justification/investigate_advise_justification.py @@ -18,9 +18,10 @@ """Expose metrics about advise justification.""" import logging -import os from typing import Dict, Any +from thoth.investigator.configuration import Configuration + from .metrics_advise_justification import advise_justification_exceptions from .metrics_advise_justification import advise_justification_success from .metrics_advise_justification import advise_justification_in_progress @@ -33,8 +34,6 @@ _LOGGER = logging.getLogger(__name__) -DEPLOYMENT_NAME = os.environ["THOTH_DEPLOYMENT_NAME"] - @register_handler(AdviseJustificationMessage().topic_name, ["v1"]) @count_exceptions(advise_justification_exceptions) @@ -44,7 +43,7 @@ async def expose_advise_justification_metrics(advise_justification: Dict[str, An advise_justification_type_number.labels( advise_message=advise_justification["message"], justification_type=advise_justification["justification_type"], - thoth_environment=DEPLOYMENT_NAME, + thoth_environment=Configuration.DEPLOYMENT_NAME, ).inc(advise_justification["count"]) _LOGGER.info( "advise_justification_type_number(%r, %r)=%r", diff --git a/thoth/investigator/configuration.py b/thoth/investigator/configuration.py index 6c1de547..d4a82e50 100644 --- a/thoth/investigator/configuration.py +++ b/thoth/investigator/configuration.py @@ -32,6 +32,8 @@ class Configuration: THOTH_BACKEND_NAMESPACE = os.environ["THOTH_BACKEND_NAMESPACE"] THOTH_MIDDLETIER_NAMESPACE = os.environ["THOTH_MIDDLETIER_NAMESPACE"] + DEPLOYMENT_NAME = os.environ["THOTH_DEPLOYMENT_NAME"] + # Workflows THOTH_INVESTIGATOR_SCHEDULE_SOLVER = int(os.getenv("THOTH_INVESTIGATOR_SCHEDULE_SOLVER", 1)) THOTH_INVESTIGATOR_SCHEDULE_REVSOLVER = int(os.getenv("THOTH_INVESTIGATOR_SCHEDULE_REVSOLVER", 1)) diff --git a/thoth/investigator/metrics.py b/thoth/investigator/metrics.py index 776916c3..56cbfbfe 100644 --- a/thoth/investigator/metrics.py +++ b/thoth/investigator/metrics.py @@ -76,6 +76,6 @@ schema_revision_metric = Gauge( "thoth_database_schema_revision_script", "Thoth database schema revision from script", - ["component", "revision"], + ["component", "revision", "env"], registry=registry, )