Skip to content

Commit

Permalink
Standardize metrics for revision check (#434)
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Murdaca <[email protected]>
  • Loading branch information
Francesco Murdaca authored Jan 26, 2021
1 parent c9e93f3 commit 7523cf8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions thoth/investigator/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion thoth/investigator/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 7523cf8

Please sign in to comment.