diff --git a/tildes/tildes/metrics.py b/tildes/tildes/metrics.py index 442508d..9f93040 100644 --- a/tildes/tildes/metrics.py +++ b/tildes/tildes/metrics.py @@ -15,6 +15,9 @@ from prometheus_client import Counter, Histogram _COUNTERS = { "votes": Counter("tildes_votes_total", "Votes", labelnames=["target_type"]), "comments": Counter("tildes_comments_total", "Comments"), + "comment_labels": Counter( + "tildes_comment_labels_total", "Comment Labels", labelnames=["label"] + ), "invite_code_failures": Counter( "tildes_invite_code_failures_total", "Invite Code Failures" ), diff --git a/tildes/tildes/models/comment/comment_label.py b/tildes/tildes/models/comment/comment_label.py index 3d95b62..bac26fb 100644 --- a/tildes/tildes/models/comment/comment_label.py +++ b/tildes/tildes/models/comment/comment_label.py @@ -12,6 +12,7 @@ from sqlalchemy.orm import backref, relationship from sqlalchemy.sql.expression import text from tildes.enums import CommentLabelOption +from tildes.metrics import incr_counter from tildes.models import DatabaseModel from tildes.models.user import User from .comment import Comment @@ -62,6 +63,8 @@ class CommentLabel(DatabaseModel): self.weight = weight self.reason = reason + incr_counter("comment_labels", label=label.name) + @property def name(self) -> str: """Return the name of the label (to avoid needing to do .label.name)."""