diff --git a/lib/gitlab/email/handler/base_handler.rb b/lib/gitlab/email/handler/base_handler.rb index 3f6ace0311a6e54b39ff04215d25ca0a2255958b..0bba433d04bfba6d726df2cb3fd0e2a11cc174f2 100644 --- a/lib/gitlab/email/handler/base_handler.rb +++ b/lib/gitlab/email/handler/base_handler.rb @@ -16,6 +16,10 @@ module Gitlab def execute raise NotImplementedError end + + def metrics_params + { handler: self.class.name } + end end end end diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb index b8ec9138c105deb984cd5ea03b8313dde86bd62b..e7f91607e7e13beb978e6d106e55314a008947ae 100644 --- a/lib/gitlab/email/handler/create_issue_handler.rb +++ b/lib/gitlab/email/handler/create_issue_handler.rb @@ -1,4 +1,3 @@ - require 'gitlab/email/handler/base_handler' module Gitlab @@ -37,6 +36,10 @@ module Gitlab @project ||= Project.find_by_full_path(project_path) end + def metrics_params + super.merge(project: project) + end + private def create_issue diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb index c66b0435f3a076bf3a1475e8728fd8c7613ec6bf..31bb775c357895fd3f02e5121a0ce5d767a045d3 100644 --- a/lib/gitlab/email/handler/create_note_handler.rb +++ b/lib/gitlab/email/handler/create_note_handler.rb @@ -28,6 +28,10 @@ module Gitlab record_name: 'comment') end + def metrics_params + super.merge(project: project) + end + private def author diff --git a/lib/gitlab/email/handler/unsubscribe_handler.rb b/lib/gitlab/email/handler/unsubscribe_handler.rb index df491f060bf662d38d99b4e0c9e5488620f2cfab..df70a0633304a209997ce996c07fa7b20b7c52a7 100644 --- a/lib/gitlab/email/handler/unsubscribe_handler.rb +++ b/lib/gitlab/email/handler/unsubscribe_handler.rb @@ -19,6 +19,10 @@ module Gitlab noteable.unsubscribe(sent_notification.recipient) end + def metrics_params + super.merge(project: project) + end + private def sent_notification diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index bb4fdd1f1f4a80af5df9706f55345e871ec67035..419d56a51e0698b125a52223f01e6cb23c5dbc42 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -1,4 +1,3 @@ - require_dependency 'gitlab/email/handler' # Inspired in great part by Discourse's Email::Receiver @@ -32,9 +31,7 @@ module Gitlab raise UnknownIncomingEmail unless handler - Gitlab::Metrics.add_event(:receive_email, - project: handler.try(:project), - handler: handler.class.name) + Gitlab::Metrics.add_event(:receive_email, handler.metrics_params) handler.execute end