summaryrefslogtreecommitdiffstats
path: root/Bugzilla/BugMail.pm
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-05-21 10:07:15 +0200
committerByron Jones <bjones@mozilla.com>2013-05-21 10:07:15 +0200
commit5143d679ac939ae894f0799bea6db51ce6b023cb (patch)
treeb5dcbddb2b4d440ddc5f7527d443cafb894852f5 /Bugzilla/BugMail.pm
parentc77550b4e47ad7835b3cc9b082136013b8c6bc7b (diff)
downloadbugzilla-5143d679ac939ae894f0799bea6db51ce6b023cb.tar.gz
bugzilla-5143d679ac939ae894f0799bea6db51ce6b023cb.tar.xz
Bug 870202: investigate ways of improving the performance of bugmail composition
Diffstat (limited to 'Bugzilla/BugMail.pm')
-rw-r--r--Bugzilla/BugMail.pm37
1 files changed, 36 insertions, 1 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index 37421ce3e..55a37c230 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -43,6 +43,7 @@ use Bugzilla::Bug;
use Bugzilla::Comment;
use Bugzilla::Mailer;
use Bugzilla::Hook;
+use Bugzilla::Instrument;
use Date::Parse;
use Date::Format;
@@ -75,6 +76,16 @@ sub Send {
my ($id, $forced, $params) = @_;
$params ||= {};
+ my $instrument;
+ my $current_login = Bugzilla->user->login;
+ if ($current_login eq 'ehsan@mozilla.com'
+ || $current_login eq 'glob@mozilla.com'
+ || $current_login eq 'dkl@mozilla.com')
+ {
+ $instrument = Bugzilla::Instrument->new('bugmail');
+ $instrument->begin("bug $id user $current_login");
+ }
+
my $dbh = Bugzilla->dbh;
my $bug = new Bugzilla::Bug($id);
@@ -155,6 +166,7 @@ sub Send {
###########################################################################
# Start of email filtering code
###########################################################################
+ $instrument && $instrument->begin('email filtering');
# A user_id => roles hash to keep track of people.
my %recipients;
@@ -213,7 +225,9 @@ sub Send {
Bugzilla::Hook::process('bugmail_recipients',
{ bug => $bug, recipients => \%recipients,
users => \%user_cache, diffs => \@diffs });
+ $instrument && $instrument->end();
+ $instrument && $instrument->begin('watchers');
if (scalar keys %recipients) {
# Find all those user-watching anyone on the current list, who is not
# on it already themselves.
@@ -240,6 +254,7 @@ sub Send {
next unless $watcher_id;
$recipients{$watcher_id}->{+REL_GLOBAL_WATCHER} = BIT_DIRECT;
}
+ $instrument && $instrument->end();
# We now have a complete set of all the users, and their relationships to
# the bug in question. However, we are not necessarily going to mail them
@@ -327,6 +342,7 @@ sub Send {
{ updated_bug => $bug,
referenced_bugs => $referenced_bugs });
+ $instrument && $instrument->begin("sending to " . $user->login);
$sent_mail = sendMail(
{ to => $user,
bug => $bug,
@@ -338,7 +354,9 @@ sub Send {
diffs => \@diffs,
rels_which_want => \%rels_which_want,
referenced_bugs => $referenced_bugs,
+ instrument => $instrument,
});
+ $instrument && $instrument->end();
}
}
@@ -359,6 +377,7 @@ sub Send {
$bug->{lastdiffed} = $end;
}
+ $instrument && $instrument->end();
return {'sent' => \@sent, 'excluded' => \@excluded};
}
@@ -374,6 +393,7 @@ sub sendMail {
my @diffs = @{ $params->{diffs} };
my $relRef = $params->{rels_which_want};
my $referenced_bugs = $params->{referenced_bugs};
+ my $instrument = $params->{instrument};
# Only display changes the user is allowed see.
my @display_diffs;
@@ -438,9 +458,14 @@ sub sendMail {
new_comments => \@send_comments,
threadingmarker => build_thread_marker($bug->id, $user->id, !$bug->lastdiffed),
referenced_bugs => $referenced_bugs,
+ instrument => $instrument,
};
+ $instrument && $instrument->begin('generating bugmail');
my $msg = _generate_bugmail($user, $vars);
+ $instrument && $instrument->end();
+ $instrument && $instrument->begin('sending to mta');
MessageToMTA($msg);
+ $instrument && $instrument->end();
return 1;
}
@@ -449,11 +474,17 @@ sub _generate_bugmail {
my ($user, $vars) = @_;
my $template = Bugzilla->template_inner($user->setting('lang'));
my ($msg_text, $msg_html, $msg_header);
-
+ my $instrument = $vars->{instrument};
+
+ $instrument && $instrument->begin('header');
$template->process("email/bugmail-header.txt.tmpl", $vars, \$msg_header)
|| ThrowTemplateError($template->error());
+ $instrument && $instrument->end();
+
+ $instrument && $instrument->begin('text body');
$template->process("email/bugmail.txt.tmpl", $vars, \$msg_text)
|| ThrowTemplateError($template->error());
+ $instrument && $instrument->end();
my @parts = (
Email::MIME->create(
@@ -464,6 +495,7 @@ sub _generate_bugmail {
)
);
if ($user->setting('email_format') eq 'html') {
+ $instrument && $instrument->begin('html body');
$template->process("email/bugmail.html.tmpl", $vars, \$msg_html)
|| ThrowTemplateError($template->error());
push @parts, Email::MIME->create(
@@ -472,8 +504,10 @@ sub _generate_bugmail {
},
body => $msg_html,
);
+ $instrument && $instrument->end();
}
+ $instrument && $instrument->begin('email object');
# TT trims the trailing newline, and threadingmarker may be ignored.
my $email = new Email::MIME("$msg_header\n");
@@ -486,6 +520,7 @@ sub _generate_bugmail {
$email->content_type_set('multipart/alternative');
}
$email->parts_set(\@parts);
+ $instrument && $instrument->end();
return $email;
}