Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHINENG-14720: Add metrics for counting host publication checks and creations #2127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions inv_publish_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from app.config import Config
from app.environment import RuntimeEnvironment
from app.logging import get_logger
from lib import metrics
from lib.handlers import ShutdownHandler
from lib.handlers import register_shutdown

Expand Down Expand Up @@ -47,10 +48,13 @@ def run(logger, session, application):
found = result.cursor.fetchone()[0]
if found:
logger.info(f'Publication "{PUBLICATION_NAME}" found!')
metrics.host_publication_success_count.inc()
else:
logger.info(f'Creating publication "{PUBLICATION_NAME}" using \n\t{CREATE_PUBLICATION}')
try:
session.execute(sa_text(CREATE_PUBLICATION))
logger.info(f'Publication "{PUBLICATION_NAME}" created!')
metrics.host_publication_success_count.inc()

# check for inactive replication_slots
replication_slots = session.execute(sa_text(CHECK_REPLICATION_SLOTS)).all()
Expand All @@ -65,6 +69,7 @@ def run(logger, session, application):
except Exception as e:
session.rollback()
logger.error(f'Error encountered when creating the publication "{PUBLICATION_NAME}" \n\t{e}')
metrics.host_publication_failure_count.inc()
raise e
else:
session.commit()
Expand Down
8 changes: 8 additions & 0 deletions lib/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@
"inventory_new_export_seconds", "Time spent to create a new host export report"
)
create_export_count = Counter("inventory_create_export", "The total amount of host exports created")

# Hosts publication checks counter
host_publication_success_count = Counter(
"inventory_host_publication_success_count", "The total amount of Hosts publication successes."
)
host_publication_failure_count = Counter(
"inventory_host_publication_failure_count", "The total amount of Hosts publication failures."
)