Browse Source

Add metric for comment labels

merge-requests/55/head
Deimos 6 years ago
parent
commit
452e22a76e
  1. 3
      tildes/tildes/metrics.py
  2. 3
      tildes/tildes/models/comment/comment_label.py

3
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"
),

3
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)."""

Loading…
Cancel
Save