summaryrefslogtreecommitdiffstats
path: root/show_bug.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'show_bug.cgi')
-rwxr-xr-xshow_bug.cgi37
1 files changed, 11 insertions, 26 deletions
diff --git a/show_bug.cgi b/show_bug.cgi
index bdd9dd5f0..f6c845ea9 100755
--- a/show_bug.cgi
+++ b/show_bug.cgi
@@ -30,19 +30,16 @@ use Bugzilla::Error;
use Bugzilla::User;
use Bugzilla::Keyword;
use Bugzilla::Bug;
+use Bugzilla::Instrument;
-use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
-use Encode qw(encode_utf8);
-use Sys::Syslog qw(:DEFAULT);
-
-my $timings = { start_time => clock_gettime(CLOCK_MONOTONIC) };
+my $timings = Bugzilla::Instrument->new('show_bug');
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
my $vars = {};
my $user = Bugzilla->login();
-$timings->{login_time} = clock_gettime(CLOCK_MONOTONIC);
+$timings->time('login_time');
my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
scalar $cgi->param('ctype'));
@@ -96,10 +93,10 @@ if ($single) {
}
}
}
-$timings->{load_bug_time} = clock_gettime(CLOCK_MONOTONIC);
+$timings->time('load_bug_time');
Bugzilla::Bug->preload(\@bugs);
-$timings->{preload_time} = clock_gettime(CLOCK_MONOTONIC);
+$timings->time('preload_time');
$vars->{'bugs'} = \@bugs;
$vars->{'marks'} = \%marks;
@@ -137,22 +134,10 @@ print $cgi->header($format->{'ctype'});
$template->process($format->{'template'}, $vars)
|| ThrowTemplateError($template->error());
-$timings->{template_time} = clock_gettime(CLOCK_MONOTONIC);
-
-_log_timings();
-
-sub _log_timings {
- return unless scalar(@bugs) == 1;
- return unless scalar(keys %$timings) == 5;
- my $entry = sprintf "show_bug bug-%s user-%s %.6f %.6f %.6f %.6f %.6f",
- $bugs[0]->id,
- $user->id,
- $timings->{template_time} - $timings->{start_time},
- $timings->{login_time} - $timings->{start_time},
- $timings->{load_bug_time} - $timings->{login_time},
- $timings->{preload_time} - $timings->{load_bug_time},
- $timings->{template_time} - $timings->{preload_time},
- openlog('apache', 'cons,pid', 'local4');
- syslog('notice', encode_utf8("[timing] $entry"));
- closelog();
+$timings->time('template_time');
+
+if (scalar(@bugs) == 1) {
+ $timings->label('bug-' . $bugs[0]->id);
+ $timings->label('user-' . $user->id);
+ $timings->log();
}