Skip to content

Commit

Permalink
Print metric and move prompusher context to narrow scope
Browse files Browse the repository at this point in the history
  • Loading branch information
voetberg committed Aug 6, 2024
1 parent c5a6bb7 commit 9483cf3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions common/check_expired_dids
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3
if __name__ == "__main__":
try:
session = get_session()
with PrometheusPusher() as manager:
statement = select(
func.count()
).select_from(
models.DataIdentifier
).where(
and_(
models.DataIdentifier.expired_at != null(),
models.DataIdentifier.expired_at < datetime.utcnow()
)
statement = select(
func.count()
).select_from(
models.DataIdentifier
).where(
and_(
models.DataIdentifier.expired_at != null(),
models.DataIdentifier.expired_at < datetime.utcnow()
)
expired_dids = session.execute(statement).scalar_one()

)
expired_dids = session.execute(statement).scalar_one()
print(expired_dids)

with PrometheusPusher() as manager:
(manager.gauge(
'expired_dids.total',
"expired_dids.total",
documentation="All expired dids")
.set(expired_dids))

except Exception:
print(traceback.format_exc())
sys.exit(UNKNOWN)
Expand Down

0 comments on commit 9483cf3

Please sign in to comment.