diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-20 14:32:12 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-04-20 14:32:12 +0000 |
commit | cc9e92a07646a2e8a193d58c1c24e837195d5a98 (patch) | |
tree | 3ff5ca1a1c5de584e5bdbb7ac30caffbec535be4 | |
parent | d58350166d267d9923d39e783600fcd95eb4cd64 (diff) | |
parent | 19970e1dba5a4c3c69ce6057814db2f37e13d1ad (diff) | |
download | gitlab-ce-cc9e92a07646a2e8a193d58c1c24e837195d5a98.tar.gz |
Merge branch 'add-email-receiver-metrics' into 'master'
Add email receiver metrics
See merge request !10814
-rw-r--r-- | changelogs/unreleased/add-email-receiver-metrics.yml | 4 | ||||
-rw-r--r-- | lib/gitlab/email/handler/create_note_handler.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/email/handler/unsubscribe_handler.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/email/receiver.rb | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/changelogs/unreleased/add-email-receiver-metrics.yml b/changelogs/unreleased/add-email-receiver-metrics.yml new file mode 100644 index 00000000000..53155651080 --- /dev/null +++ b/changelogs/unreleased/add-email-receiver-metrics.yml @@ -0,0 +1,4 @@ +--- +title: Add metrics events for incoming emails +merge_request: +author: diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb index 0e22f2189ee..c66b0435f3a 100644 --- a/lib/gitlab/email/handler/create_note_handler.rb +++ b/lib/gitlab/email/handler/create_note_handler.rb @@ -7,6 +7,8 @@ module Gitlab class CreateNoteHandler < BaseHandler include ReplyProcessing + delegate :project, to: :sent_notification, allow_nil: true + def can_handle? mail_key =~ /\A\w+\z/ end @@ -32,10 +34,6 @@ module Gitlab sent_notification.recipient end - def project - sent_notification.project - end - def sent_notification @sent_notification ||= SentNotification.for(mail_key) end diff --git a/lib/gitlab/email/handler/unsubscribe_handler.rb b/lib/gitlab/email/handler/unsubscribe_handler.rb index 97d7a8d65ff..df491f060bf 100644 --- a/lib/gitlab/email/handler/unsubscribe_handler.rb +++ b/lib/gitlab/email/handler/unsubscribe_handler.rb @@ -4,6 +4,8 @@ module Gitlab module Email module Handler class UnsubscribeHandler < BaseHandler + delegate :project, to: :sent_notification, allow_nil: true + def can_handle? mail_key =~ /\A\w+#{Regexp.escape(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX)}\z/ end diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index ec0529b5a4b..bb4fdd1f1f4 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -32,6 +32,10 @@ module Gitlab raise UnknownIncomingEmail unless handler + Gitlab::Metrics.add_event(:receive_email, + project: handler.try(:project), + handler: handler.class.name) + handler.execute end |