Commit 35f57028 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'email-handler-metrics-ee' into 'master'

Make handler metric params more explicit

See merge request !1696
parents d2ec8706 3f5f10cb
---
title: Add metrics events for incoming emails
merge_request:
author:
...@@ -16,6 +16,10 @@ module Gitlab ...@@ -16,6 +16,10 @@ module Gitlab
def execute def execute
raise NotImplementedError raise NotImplementedError
end end
def metrics_params
{ handler: self.class.name }
end
end end
end end
end end
......
require 'gitlab/email/handler/base_handler' require 'gitlab/email/handler/base_handler'
module Gitlab module Gitlab
...@@ -37,6 +36,10 @@ module Gitlab ...@@ -37,6 +36,10 @@ module Gitlab
@project ||= Project.find_by_full_path(project_path) @project ||= Project.find_by_full_path(project_path)
end end
def metrics_params
super.merge(project: project)
end
private private
def create_issue def create_issue
......
...@@ -7,6 +7,8 @@ module Gitlab ...@@ -7,6 +7,8 @@ module Gitlab
class CreateNoteHandler < BaseHandler class CreateNoteHandler < BaseHandler
include ReplyProcessing include ReplyProcessing
delegate :project, to: :sent_notification, allow_nil: true
def can_handle? def can_handle?
mail_key =~ /\A\w+\z/ mail_key =~ /\A\w+\z/
end end
...@@ -26,16 +28,16 @@ module Gitlab ...@@ -26,16 +28,16 @@ module Gitlab
record_name: 'comment') record_name: 'comment')
end end
def metrics_params
super.merge(project: project)
end
private private
def author def author
sent_notification.recipient sent_notification.recipient
end end
def project
sent_notification.project
end
def sent_notification def sent_notification
@sent_notification ||= SentNotification.for(mail_key) @sent_notification ||= SentNotification.for(mail_key)
end end
......
...@@ -16,6 +16,10 @@ module Gitlab ...@@ -16,6 +16,10 @@ module Gitlab
send_thank_you_email! if from_address send_thank_you_email! if from_address
end end
def metrics_params
super.merge(project: project)
end
private private
def service_desk_key def service_desk_key
......
...@@ -4,6 +4,8 @@ module Gitlab ...@@ -4,6 +4,8 @@ module Gitlab
module Email module Email
module Handler module Handler
class UnsubscribeHandler < BaseHandler class UnsubscribeHandler < BaseHandler
delegate :project, to: :sent_notification, allow_nil: true
def can_handle? def can_handle?
mail_key =~ /\A\w+#{Regexp.escape(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX)}\z/ mail_key =~ /\A\w+#{Regexp.escape(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX)}\z/
end end
...@@ -17,6 +19,10 @@ module Gitlab ...@@ -17,6 +19,10 @@ module Gitlab
noteable.unsubscribe(sent_notification.recipient) noteable.unsubscribe(sent_notification.recipient)
end end
def metrics_params
super.merge(project: project)
end
private private
def sent_notification def sent_notification
......
require_dependency 'gitlab/email/handler' require_dependency 'gitlab/email/handler'
# Inspired in great part by Discourse's Email::Receiver # Inspired in great part by Discourse's Email::Receiver
...@@ -32,6 +31,8 @@ module Gitlab ...@@ -32,6 +31,8 @@ module Gitlab
raise UnknownIncomingEmail unless handler raise UnknownIncomingEmail unless handler
Gitlab::Metrics.add_event(:receive_email, handler.metrics_params)
handler.execute handler.execute
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment