From d5f2d8158b90a55cefe126e38132e390e9fa75f5 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 28 Jun 2018 23:26:52 -0400 Subject: Bug 1472048 - Remove Metrics Code --- Bugzilla/Config/Advanced.pm | 31 ------ Bugzilla/Install/Filesystem.pm | 1 - Bugzilla/Metrics/Collector.pm | 171 ----------------------------- Bugzilla/Metrics/Memcached.pm | 24 ---- Bugzilla/Metrics/Mysql.pm | 148 ------------------------- Bugzilla/Metrics/Reporter.pm | 103 ----------------- Bugzilla/Metrics/Reporter/ElasticSearch.pm | 105 ------------------ Bugzilla/Metrics/Reporter/STDERR.pm | 152 ------------------------- Bugzilla/Metrics/Template.pm | 24 ---- Bugzilla/Metrics/Template/Context.pm | 30 ----- Bugzilla/Template.pm | 5 +- Bugzilla/WebService/Server.pm | 5 - 12 files changed, 1 insertion(+), 798 deletions(-) delete mode 100644 Bugzilla/Metrics/Collector.pm delete mode 100644 Bugzilla/Metrics/Memcached.pm delete mode 100644 Bugzilla/Metrics/Mysql.pm delete mode 100644 Bugzilla/Metrics/Reporter.pm delete mode 100644 Bugzilla/Metrics/Reporter/ElasticSearch.pm delete mode 100644 Bugzilla/Metrics/Reporter/STDERR.pm delete mode 100644 Bugzilla/Metrics/Template.pm delete mode 100644 Bugzilla/Metrics/Template/Context.pm (limited to 'Bugzilla') diff --git a/Bugzilla/Config/Advanced.pm b/Bugzilla/Config/Advanced.pm index 9316d8e48..398f02701 100644 --- a/Bugzilla/Config/Advanced.pm +++ b/Bugzilla/Config/Advanced.pm @@ -36,37 +36,6 @@ use constant get_param_list => ( type => 'b', default => 0 }, - - { - name => 'metrics_enabled', - type => 'b', - default => 0 - }, - { - name => 'metrics_user_ids', - type => 't', - default => '3881,5038,5898,13647,20209,251051,373476,409787' - }, - { - name => 'metrics_elasticsearch_server', - type => 't', - default => '127.0.0.1:9200' - }, - { - name => 'metrics_elasticsearch_index', - type => 't', - default => 'bmo-metrics' - }, - { - name => 'metrics_elasticsearch_type', - type => 't', - default => 'timings' - }, - { - name => 'metrics_elasticsearch_ttl', - type => 't', - default => '1210000000' # 14 days - }, ); 1; diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index 094226891..003be22e4 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -225,7 +225,6 @@ sub FILESYSTEM { 'runtests.pl' => { perms => OWNER_EXECUTE }, 'jobqueue.pl' => { perms => OWNER_EXECUTE }, 'migrate.pl' => { perms => OWNER_EXECUTE }, - 'metrics.pl' => { perms => WS_EXECUTE }, 'Makefile.PL' => { perms => OWNER_EXECUTE }, 'gen-cpanfile.pl' => { perms => OWNER_EXECUTE }, 'jobqueue-worker.pl' => { perms => OWNER_EXECUTE }, diff --git a/Bugzilla/Metrics/Collector.pm b/Bugzilla/Metrics/Collector.pm deleted file mode 100644 index 53cbac819..000000000 --- a/Bugzilla/Metrics/Collector.pm +++ /dev/null @@ -1,171 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Collector; - -use strict; -use warnings; -use 5.10.1; - -# the reporter needs to be a constant and use'd here to ensure it's loaded at -# compile time. -use constant REPORTER => 'Bugzilla::Metrics::Reporter::ElasticSearch'; -use Bugzilla::Metrics::Reporter::ElasticSearch; - -# Debugging reporter -#use constant REPORTER => 'Bugzilla::Metrics::Reporter::STDERR'; -#use Bugzilla::Metrics::Reporter::STDERR; - -use Bugzilla::Constants; -use Cwd qw(abs_path); -use File::Basename; -use Time::HiRes qw(gettimeofday clock_gettime CLOCK_MONOTONIC); - -sub new { - my ($class, $name) = @_; - my $self = { - root => undef, - head => undef, - time => scalar(gettimeofday()), - }; - bless($self, $class); - $self->_start_timer({ type => 'main', name => $name }); - return $self; -} - -sub end { - my ($self, $timer) = @_; - my $is_head = $timer ? 0 : 1; - $timer ||= $self->{head}; - $timer->{duration} += clock_gettime(CLOCK_MONOTONIC) - $timer->{start_time}; - $self->{head} = $self->{head}->{parent} if $is_head; -} - -sub cancel { - my ($self) = @_; - delete $self->{head}; -} - -sub DESTROY { - my ($self) = @_; - $self->finish() if $self->{head}; -} - -sub finish { - my ($self) = @_; - $self->end($self->{root}); - delete $self->{head}; - - my $user = Bugzilla->user; - if ($ENV{MOD_PERL}) { - require Apache2::RequestUtil; - my $request = eval { Apache2::RequestUtil->request }; - my $headers = $request ? $request->headers_in() : {}; - $self->{env} = { - referer => $headers->{Referer}, - request_method => $request->method, - request_uri => basename($request->unparsed_uri), - script_name => $request->uri, - user_agent => $headers->{'User-Agent'}, - }; - } - else { - $self->{env} = { - referer => $ENV{HTTP_REFERER}, - request_method => $ENV{REQUEST_METHOD}, - request_uri => $ENV{REQUEST_URI}, - script_name => basename($ENV{SCRIPT_NAME}), - user_agent => $ENV{HTTP_USER_AGENT}, - }; - } - $self->{env}->{name} = $self->{root}->{name}; - $self->{env}->{time} = $self->{time}; - $self->{env}->{user_id} = $user->id; - $self->{env}->{login} = $user->login if $user->id; - - # remove passwords from request_uri - $self->{env}->{request_uri} =~ s/\b((?:bugzilla_)?password=)(?:[^&]+|.+$)/$1x/gi; - - $self->report(); -} - -sub name { - my ($self, $value) = @_; - $self->{root}->{name} = $value if defined $value; - return $self->{root}->{name}; -} - -sub db_start { - my ($self) = @_; - my $timer = $self->_start_timer({ type => 'db' }); - - my @stack; - my $i = 0; - state $path = quotemeta(abs_path(bz_locations()->{cgi_path}) . '/'); - while (1) { - my @caller = caller($i); - last unless @caller; - my $file = $caller[1]; - $file =~ s/^$path//o; - push @stack, "$file:$caller[2]" - unless substr($file, 0, 16) eq 'Bugzilla/Metrics'; - last if $file =~ /\.(?:tmpl|cgi)$/; - $i++; - } - $timer->{stack} = \@stack; - - return $timer; -} - -sub template_start { - my ($self, $file) = @_; - $self->_start_timer({ type => 'tmpl', file => $file }); -} - -sub memcached_start { - my ($self, $key) = @_; - $self->_start_timer({ type => 'memcached', key => $key }); -} - -sub memcached_end { - my ($self, $hit) = @_; - $self->{head}->{result} = $hit ? 'hit' : 'miss'; - $self->end(); -} - -sub resume { - my ($self, $timer) = @_; - $timer->{start_time} = clock_gettime(CLOCK_MONOTONIC); - return $timer; -} - -sub _start_timer { - my ($self, $timer) = @_; - $timer->{start_time} = $timer->{first_time} = clock_gettime(CLOCK_MONOTONIC); - $timer->{duration} = 0; - $timer->{children} = []; - - if ($self->{head}) { - $timer->{parent} = $self->{head}; - push @{ $self->{head}->{children} }, $timer; - } - else { - $timer->{parent} = undef; - $self->{root} = $timer; - } - $self->{head} = $timer; - - return $timer; -} - -sub report { - my ($self) = @_; - my $class = REPORTER; - $class->DETACH ? $class->background($self) : $class->foreground($self); -} - -1; diff --git a/Bugzilla/Metrics/Memcached.pm b/Bugzilla/Metrics/Memcached.pm deleted file mode 100644 index b640f9280..000000000 --- a/Bugzilla/Metrics/Memcached.pm +++ /dev/null @@ -1,24 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Memcached; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::Memcached'; - -sub _get { - my $self = shift; - Bugzilla->metrics->memcached_start($_[0]); - my $result = $self->SUPER::_get(@_); - Bugzilla->metrics->memcached_end($result); - return $result; -} - -1; diff --git a/Bugzilla/Metrics/Mysql.pm b/Bugzilla/Metrics/Mysql.pm deleted file mode 100644 index 60dff78c8..000000000 --- a/Bugzilla/Metrics/Mysql.pm +++ /dev/null @@ -1,148 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Mysql; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::DB::Mysql'; - -sub do { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::do(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub selectall_arrayref { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::selectall_arrayref(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub selectall_hashref { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::selectall_hashref(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub selectcol_arrayref { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::selectcol_arrayref(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub selectrow_array { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my @result = $self->SUPER::selectrow_array(@args); - Bugzilla->metrics->end(); - return wantarray ? @result : $result[0]; -} - -sub selectrow_arrayref { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::selectrow_arrayref(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub selectrow_hashref { - my ($self, @args) = @_; - Bugzilla->metrics->db_start($args[0]); - my $result = $self->SUPER::selectrow_hashref(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub commit { - my ($self, @args) = @_; - Bugzilla->metrics->db_start('COMMIT'); - my $result = $self->SUPER::commit(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub prepare { - my ($self, @args) = @_; - my $sth = $self->SUPER::prepare(@args); - bless($sth, 'Bugzilla::Metrics::st'); - return $sth; -} - -package Bugzilla::Metrics::st; - -use 5.10.1; -use strict; -use warnings; - -use base 'DBI::st'; - -sub execute { - my ($self, @args) = @_; - $self->{private_timer} = Bugzilla->metrics->db_start(); - my $result = $self->SUPER::execute(@args); - Bugzilla->metrics->end(); - return $result; -} - -sub fetchrow_array { - my ($self, @args) = @_; - my $timer = $self->{private_timer}; - Bugzilla->metrics->resume($timer); - my @result = $self->SUPER::fetchrow_array(@args); - Bugzilla->metrics->end($timer); - return wantarray ? @result : $result[0]; -} - -sub fetchrow_arrayref { - my ($self, @args) = @_; - my $timer = $self->{private_timer}; - Bugzilla->metrics->resume($timer); - my $result = $self->SUPER::fetchrow_arrayref(@args); - Bugzilla->metrics->end($timer); - return $result; -} - -sub fetchrow_hashref { - my ($self, @args) = @_; - my $timer = $self->{private_timer}; - Bugzilla->metrics->resume($timer); - my $result = $self->SUPER::fetchrow_hashref(@args); - Bugzilla->metrics->end($timer); - return $result; -} - -sub fetchall_arrayref { - my ($self, @args) = @_; - my $timer = $self->{private_timer}; - Bugzilla->metrics->resume($timer); - my $result = $self->SUPER::fetchall_arrayref(@args); - Bugzilla->metrics->end($timer); - return $result; -} - -sub fetchall_hashref { - my ($self, @args) = @_; - my $timer = $self->{private_timer}; - Bugzilla->metrics->resume($timer); - my $result = $self->SUPER::fetchall_hashref(@args); - Bugzilla->metrics->end($timer); - return $result; -} - -1; diff --git a/Bugzilla/Metrics/Reporter.pm b/Bugzilla/Metrics/Reporter.pm deleted file mode 100644 index 8216ea923..000000000 --- a/Bugzilla/Metrics/Reporter.pm +++ /dev/null @@ -1,103 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Reporter; - -use 5.10.1; -use strict; -use warnings; - -use Bugzilla::Constants; -use File::Slurp; -use File::Temp; -use JSON; - -# most reporters should detach from the httpd process. -# reporters which do not detach will block completion of the http response. -use constant DETACH => 1; - -# class method to start the delivery script in the background -sub background { - my ($class, $collector) = @_; - - # we need to remove parent links to avoid looped structures, which - # encode_json chokes on - _walk_timers($collector->{root}, sub { delete $_[0]->{parent} }); - - # serialisation - my $json = encode_json({ env => $collector->{env}, times => $collector->{root} }); - - # write to temp filename - my $fh = File::Temp->new( UNLINK => 0 ); - if (!$fh) { - warn "Failed to create temp file: $!\n"; - return; - } - binmode($fh, ':utf8'); - print $fh $json; - close($fh) or die "$fh : $!"; - my $filename = $fh->filename; - - # spawn delivery worker - my $command = bz_locations()->{'cgi_path'} . "/metrics.pl '$class' '$filename' &"; - $ENV{PATH} = ''; - system($command); -} - -# run the reporter immediately -sub foreground { - my ($class, $collector) = @_; - my $reporter = $class->new({ hashref => { env => $collector->{env}, times => $collector->{root} } }); - $reporter->report(); -} - -sub new { - my ($invocant, $args) = @_; - my $class = ref($invocant) || $invocant; - - # load from either a json_filename or hashref - my $self; - if ($args->{json_filename}) { - $self = decode_json(read_file($args->{json_filename}, binmode => ':utf8')); - unlink($args->{json_filename}); - } - else { - $self = $args->{hashref}; - } - bless($self, $class); - - # remove redundant data - $self->walk_timers(sub { - my ($timer) = @_; - $timer->{start_time} = delete $timer->{first_time}; - delete $timer->{children} - if exists $timer->{children} && !scalar(@{ $timer->{children} }); - }); - - return $self; -} - -sub walk_timers { - my ($self, $callback) = @_; - _walk_timers($self->{times}, $callback, undef); -} - -sub _walk_timers { - my ($timer, $callback, $parent) = @_; - $callback->($timer, $parent); - if (exists $timer->{children}) { - foreach my $child (@{ $timer->{children} }) { - _walk_timers($child, $callback, $timer); - } - } -} - -sub report { - die "abstract method call"; -} - -1; diff --git a/Bugzilla/Metrics/Reporter/ElasticSearch.pm b/Bugzilla/Metrics/Reporter/ElasticSearch.pm deleted file mode 100644 index c61a1d750..000000000 --- a/Bugzilla/Metrics/Reporter/ElasticSearch.pm +++ /dev/null @@ -1,105 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Reporter::ElasticSearch; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::Metrics::Reporter'; - -use constant DETACH => 1; - -sub report { - my ($self) = @_; - - # build path array and flatten - my @timers; - $self->walk_timers(sub { - my ($timer, $parent) = @_; - $timer->{id} = scalar(@timers); - if ($parent) { - if (exists $timer->{children}) { - if ($timer->{type} eq 'tmpl') { - $timer->{node} = 'tmpl: ' . $timer->{file}; - } - elsif ($timer->{type} eq 'db') { - $timer->{node} = 'db'; - } - else { - $timer->{node} = '?'; - } - } - $timer->{path} = [ @{ $parent->{path} }, $parent->{node} ]; - $timer->{parent} = $parent->{id}; - } - else { - $timer->{path} = [ ]; - $timer->{node} = $timer->{name}; - } - push @timers, $timer; - }); - - # calculate timer-only durations - $self->walk_timers(sub { - my ($timer) = @_; - my $child_duration = 0; - if (exists $timer->{children}) { - foreach my $child (@{ $timer->{children} }) { - $child_duration += $child->{duration}; - } - } - $timer->{this_duration} = $timer->{duration} - $child_duration; - }); - - # massage each timer - my $start_time = $self->{times}->{start_time}; - foreach my $timer (@timers) { - # remove node name and children - delete $timer->{node}; - delete $timer->{children}; - - # show relative times - $timer->{start_time} = $timer->{start_time} - $start_time; - delete $timer->{end_time}; - - # show times in ms instead of fractional seconds - foreach my $field (qw( start_time duration this_duration )) { - $timer->{$field} = sprintf('%.4f', $timer->{$field} * 1000) * 1; - } - } - - # remove private data from env - delete $self->{env}->{user_agent}; - delete $self->{env}->{referer}; - - # throw at ES - require ElasticSearch; - my $es = ElasticSearch->new( - servers => Bugzilla->params->{metrics_elasticsearch_server}, - transport => 'http', - ); - # the ElasticSearch module queries the server for a list of nodes and - # connects directly to a random node. that bypasses our load balancer so we - # disable that by setting the server list directly. - $es->transport->servers(Bugzilla->params->{metrics_elasticsearch_server}); - # as the discovered node list is lazy-loaded, increase _refresh_in so it - # won't call ->refresh_servers() - $es->transport->{_refresh_in} = 1; - $es->index( - index => Bugzilla->params->{metrics_elasticsearch_index}, - type => Bugzilla->params->{metrics_elasticsearch_type}, - ttl => Bugzilla->params->{metrics_elasticsearch_ttl}, - data => { - env => $self->{env}, - times => \@timers, - }, - ); -} - -1; diff --git a/Bugzilla/Metrics/Reporter/STDERR.pm b/Bugzilla/Metrics/Reporter/STDERR.pm deleted file mode 100644 index a61cdb25f..000000000 --- a/Bugzilla/Metrics/Reporter/STDERR.pm +++ /dev/null @@ -1,152 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Reporter::STDERR; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::Metrics::Reporter'; - -use Data::Dumper; - -use constant DETACH => 0; - -sub report { - my ($self) = @_; - - # count totals - $self->{total} = $self->{times}->{duration}; - $self->{tmpl_count} = $self->{db_count} = $self->{mem_count} = 0; - $self->{total_tmpl} = $self->{total_db} = $self->{mem_hits} = 0; - $self->{mem_keys} = {}; - $self->_tally($self->{times}); - - # calculate percentages - $self->{other} = $self->{total} - $self->{total_tmpl} - $self->{total_db}; - if ($self->{total} * 1) { - $self->{perc_tmpl} = $self->{total_tmpl} / $self->{total} * 100; - $self->{perc_db} = $self->{total_db} / $self->{total} * 100; - $self->{perc_other} = $self->{other} / $self->{total} * 100; - } else { - $self->{perc_tmpl} = 0; - $self->{perc_db} = 0; - $self->{perc_other} = 0; - } - if ($self->{mem_count}) { - $self->{perc_mem} = $self->{mem_hits} / $self->{mem_count} * 100; - } else { - $self->{perm_mem} = 0; - } - - # convert to ms and format - foreach my $key (qw( total total_tmpl total_db other )) { - $self->{$key} = sprintf("%.4f", $self->{$key} * 1000); - } - foreach my $key (qw( perc_tmpl perc_db perc_other perc_mem )) { - $self->{$key} = sprintf("%.1f", $self->{$key}); - } - - # massage each timer - my $start_time = $self->{times}->{start_time}; - $self->walk_timers(sub { - my ($timer) = @_; - delete $timer->{parent}; - - # show relative times - $timer->{start_time} = $timer->{start_time} - $start_time; - delete $timer->{end_time}; - - # show times in ms instead of fractional seconds - foreach my $field (qw( start_time duration duration_this )) { - $timer->{$field} = sprintf('%.4f', $timer->{$field} * 1000) * 1 - if exists $timer->{$field}; - } - }); - - if (0) { - # dump timers to stderr - local $Data::Dumper::Indent = 1; - local $Data::Dumper::Terse = 1; - local $Data::Dumper::Sortkeys = sub { - my ($rh) = @_; - return [ sort { $b cmp $a } keys %$rh ]; - }; - print STDERR Dumper($self->{env}); - print STDERR Dumper($self->{times}); - } - - # summary summary table too - print STDERR <{total} - tmpl time: $self->{total_tmpl} ($self->{perc_tmpl}%) $self->{tmpl_count} hits - db time: $self->{total_db} ($self->{perc_db}%) $self->{db_count} hits -other time: $self->{other} ($self->{perc_other}%) - memcached: $self->{perc_mem}% ($self->{mem_count} requests) -EOF - my $tmpls = $self->{tmpl}; - my $len = 0; - foreach my $file (keys %$tmpls) { - $len = length($file) if length($file) > $len; - } - foreach my $file (sort { $tmpls->{$b}->{count} <=> $tmpls->{$a}->{count} } keys %$tmpls) { - my $tmpl = $tmpls->{$file}; - printf STDERR - "%${len}s: %2s hits %8.4f total %8.4f avg\n", - $file, - $tmpl->{count}, - $tmpl->{duration} * 1000, - $tmpl->{duration} * 1000 / $tmpl->{count} - ; - } - my $keys = $self->{mem_keys}; - $len = 0; - foreach my $key (keys %$keys) { - $len = length($key) if length($key) > $len; - } - foreach my $key (sort { $keys->{$a} <=> $keys->{$b} or $a cmp $b } keys %$keys) { - printf STDERR "%${len}s: %s\n", $key, $keys->{$key}; - } -} - -sub _tally { - my ($self, $timer) = @_; - if (exists $timer->{children}) { - foreach my $child (@{ $timer->{children} }) { - $self->_tally($child); - } - } - - if ($timer->{type} eq 'db') { - $timer->{duration_this} = $timer->{duration}; - $self->{total_db} += $timer->{duration}; - $self->{db_count}++; - - } elsif ($timer->{type} eq 'tmpl') { - my $child_duration = 0; - if (exists $timer->{children}) { - foreach my $child (@{ $timer->{children} }) { - $child_duration += $child->{duration}; - } - } - $timer->{duration_this} = $timer->{duration} - $child_duration; - - $self->{total_tmpl} += $timer->{duration} - $child_duration; - $self->{tmpl_count}++; - $self->{tmpl}->{$timer->{file}}->{count}++; - $self->{tmpl}->{$timer->{file}}->{duration} += $timer->{duration}; - - } elsif ($timer->{type} eq 'memcached') { - $timer->{duration_this} = $timer->{duration}; - $self->{mem_count}++; - $self->{mem_keys}->{$timer->{key}}++; - $self->{mem_hits}++ if $timer->{result} eq 'hit'; - } -} - -1; diff --git a/Bugzilla/Metrics/Template.pm b/Bugzilla/Metrics/Template.pm deleted file mode 100644 index 5d9af240e..000000000 --- a/Bugzilla/Metrics/Template.pm +++ /dev/null @@ -1,24 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Template; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::Template'; - -sub process { - my $self = shift; - Bugzilla->metrics->template_start($_[0]); - my $result = $self->SUPER::process(@_); - Bugzilla->metrics->end(); - return $result; -} - -1; diff --git a/Bugzilla/Metrics/Template/Context.pm b/Bugzilla/Metrics/Template/Context.pm deleted file mode 100644 index 278cfce1e..000000000 --- a/Bugzilla/Metrics/Template/Context.pm +++ /dev/null @@ -1,30 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Metrics::Template::Context; - -use 5.10.1; -use strict; -use warnings; - -use base 'Bugzilla::Template::Context'; - -sub process { - my $self = shift; - - # we only want to measure files not template blocks - if (ref($_[0]) || substr($_[0], -5) ne '.tmpl') { - return $self->SUPER::process(@_); - } - - Bugzilla->metrics->template_start($_[0]); - my $result = $self->SUPER::process(@_); - Bugzilla->metrics->end(); - return $result; -} - -1; diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index ae4f9bbad..9eea0d3dd 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -1050,10 +1050,7 @@ sub create { $SHARED_PROVIDERS{$provider_key} ||= $provider_class->new($config); $config->{LOAD_TEMPLATES} = [ $SHARED_PROVIDERS{$provider_key} ]; - # BMO - use metrics subclass - local $Template::Config::CONTEXT = Bugzilla->metrics_enabled() - ? 'Bugzilla::Metrics::Template::Context' - : 'Bugzilla::Template::Context'; + local $Template::Config::CONTEXT = 'Bugzilla::Template::Context'; Bugzilla::Hook::process('template_before_create', { config => $config }); my $template = $class->new($config) diff --git a/Bugzilla/WebService/Server.pm b/Bugzilla/WebService/Server.pm index ba9847abc..a76c4c48c 100644 --- a/Bugzilla/WebService/Server.pm +++ b/Bugzilla/WebService/Server.pm @@ -23,11 +23,6 @@ sub handle_login { # Throw error if the supplied class does not exist or the method is private ThrowCodeError('unknown_method', {method => $full_method}) if (!$class or $method =~ /^_/); - # BMO - use the class and method as the name, instead of the cgi filename - if (Bugzilla->metrics_enabled) { - Bugzilla->metrics->name("$class $method"); - } - # We never want to create a new session unless the user is calling the # login method. Setting dont_persist_session makes # Bugzilla::Auth::_handle_login_result() skip calling persist_login(). -- cgit v1.2.3-24-g4f1b