add some more metrics for answers and comments
This commit is contained in:
parent
64adbb5707
commit
b937a10096
|
@ -115,6 +115,8 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
raise Errors::AnsweringSelfBlockedOther if self.blocking?(question.user)
|
raise Errors::AnsweringSelfBlockedOther if self.blocking?(question.user)
|
||||||
# rubocop:enable Style/RedundantSelf
|
# rubocop:enable Style/RedundantSelf
|
||||||
|
|
||||||
|
Retrospring::Metrics::QUESTIONS_ANSWERED.increment
|
||||||
|
|
||||||
Answer.create!(content:, user: self, question:)
|
Answer.create!(content:, user: self, question:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,6 +130,8 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
raise Errors::CommentingOtherBlockedSelf if answer.user.blocking?(self)
|
raise Errors::CommentingOtherBlockedSelf if answer.user.blocking?(self)
|
||||||
# rubocop:enable Style/RedundantSelf
|
# rubocop:enable Style/RedundantSelf
|
||||||
|
|
||||||
|
Retrospring::Metrics::COMMENTS_CREATED.increment
|
||||||
|
|
||||||
Comment.create!(user: self, answer:, content:)
|
Comment.create!(user: self, answer:, content:)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Retrospring
|
||||||
module Metrics
|
module Metrics
|
||||||
PROMETHEUS = Prometheus::Client.registry
|
PROMETHEUS = Prometheus::Client.registry
|
||||||
|
|
||||||
# avoid re-registering metrics to make autoreloader happy:
|
# avoid re-registering metrics to make autoreloader happy during dev:
|
||||||
class << self
|
class << self
|
||||||
%i[counter gauge histogram summary].each do |meth|
|
%i[counter gauge histogram summary].each do |meth|
|
||||||
define_method meth do |name, *args, **kwargs|
|
define_method meth do |name, *args, **kwargs|
|
||||||
|
@ -32,5 +32,15 @@ module Retrospring
|
||||||
docstring: "How many questions got asked",
|
docstring: "How many questions got asked",
|
||||||
labels: %i[anonymous followers generated]
|
labels: %i[anonymous followers generated]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
QUESTIONS_ANSWERED = counter(
|
||||||
|
:retrospring_questions_answered_total,
|
||||||
|
docstring: "How many questions got answered"
|
||||||
|
)
|
||||||
|
|
||||||
|
COMMENTS_CREATED = counter(
|
||||||
|
:retrospring_comments_created_total,
|
||||||
|
docstring: "How many comments got created"
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue