diff --git a/lib/JSONReportFormatter.pm b/lib/JSONReportFormatter.pm index ab981ade..807334f0 100644 --- a/lib/JSONReportFormatter.pm +++ b/lib/JSONReportFormatter.pm @@ -1,3 +1,22 @@ +# This program is copyright 2013 Percona Ireland Ltd. +# Feedback and improvements are welcome. +# +# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar +# systems, you can issue `man perlgpl' or `man perlartistic' to read these +# licenses. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 59 Temple +# Place, Suite 330, Boston, MA 02111-1307 USA. +# ########################################################################### +# JSONReportFormatter package +# ########################################################################### { package JSONReportFormatter; use Lmo; @@ -57,8 +76,6 @@ override query_report => sub { my @attribs = @{$ea->get_attributes()}; - my %string_args = map { $_ => 1 } qw( db host arg user bytes pos_in_log ); - my @queries; foreach my $worst_info ( @$worst ) { my $item = $worst_info->[0]; @@ -98,7 +115,7 @@ override query_report => sub { $class{ts_min} = $ts->{min}; $class{ts_max} = $ts->{max}; } - elsif ( $string_args{$attrib} ) { + elsif ( ($ea->{type_for}->{$attrib} || '') eq 'str' ) { $metrics{$attrib} = { value => $metrics{$attrib}{max} }; } elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) { @@ -128,3 +145,6 @@ override query_report => sub { no Lmo; 1; } +# ########################################################################### +# End JSONReportFormatter package +# ########################################################################### diff --git a/t/pt-query-digest/output.t b/t/pt-query-digest/json.t similarity index 98% rename from t/pt-query-digest/output.t rename to t/pt-query-digest/json.t index f61bb572..21513543 100644 --- a/t/pt-query-digest/output.t +++ b/t/pt-query-digest/json.t @@ -28,7 +28,7 @@ ok( "$results/empty_report.txt", ), 'json output for empty log' -); +) or diag($test_diff); ok( no_diff( diff --git a/t/pt-query-digest/samples/empty_report.txt b/t/pt-query-digest/samples/empty_report.txt index a05997d5..e69de29b 100644 --- a/t/pt-query-digest/samples/empty_report.txt +++ b/t/pt-query-digest/samples/empty_report.txt @@ -1,2 +0,0 @@ - -# No events processed.