Skip to content

Commit 9483cf3

Browse files
committed
Print metric and move prompusher context to narrow scope
1 parent c5a6bb7 commit 9483cf3

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

common/check_expired_dids

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ OK, WARNING, CRITICAL, UNKNOWN = 0, 1, 2, 3
3434
if __name__ == "__main__":
3535
try:
3636
session = get_session()
37-
with PrometheusPusher() as manager:
38-
statement = select(
39-
func.count()
40-
).select_from(
41-
models.DataIdentifier
42-
).where(
43-
and_(
44-
models.DataIdentifier.expired_at != null(),
45-
models.DataIdentifier.expired_at < datetime.utcnow()
46-
)
37+
statement = select(
38+
func.count()
39+
).select_from(
40+
models.DataIdentifier
41+
).where(
42+
and_(
43+
models.DataIdentifier.expired_at != null(),
44+
models.DataIdentifier.expired_at < datetime.utcnow()
4745
)
48-
expired_dids = session.execute(statement).scalar_one()
49-
46+
)
47+
expired_dids = session.execute(statement).scalar_one()
48+
print(expired_dids)
49+
50+
with PrometheusPusher() as manager:
5051
(manager.gauge(
51-
'expired_dids.total',
52+
"expired_dids.total",
5253
documentation="All expired dids")
5354
.set(expired_dids))
54-
5555
except Exception:
5656
print(traceback.format_exc())
5757
sys.exit(UNKNOWN)

0 commit comments

Comments
 (0)