Make some internal values show up nicer in --output json

This commit is contained in:
Brian Fraser
2013-03-05 02:50:13 -03:00
parent 310867b301
commit 91052e7198
4 changed files with 28 additions and 130 deletions

View File

@@ -9,8 +9,8 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
my $have_json = eval { require JSON };
our $pretty_json = undef;
our $sorted_json = undef;
our $pretty_json = 0;
our $sorted_json = 0;
extends qw(QueryReportFormatter);
@@ -56,6 +56,8 @@ override query_report => sub {
my $worst = $args{worst};
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 ) {
@@ -96,6 +98,9 @@ override query_report => sub {
$class{ts_min} = $ts->{min};
$class{ts_max} = $ts->{max};
}
elsif ( $string_args{$attrib} ) {
$metrics{$attrib} = { value => $metrics{$attrib}{max} };
}
elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) {
# Avoid scientific notation in the metrics by forcing it to use
# six decimal places.