diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 01bf5e1f..4e779928 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -8049,11 +8049,13 @@ override query_report => sub { elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) { for my $value ( values %{$metrics{$attrib}} ) { next unless $value; - $value = sprintf '%.7f', $value; + $value = sprintf '%.6f', $value; + } + if ( my $pct = $metrics{$attrib}->{pct} ) { + $metrics{$attrib}->{pct} = sprintf('%.2f', $pct); } } } - push @queries, { class => \%class, attributes => \%metrics, diff --git a/lib/JSONReportFormatter.pm b/lib/JSONReportFormatter.pm index e2cc0a31..331e08de 100644 --- a/lib/JSONReportFormatter.pm +++ b/lib/JSONReportFormatter.pm @@ -71,13 +71,18 @@ override query_report => sub { $class{ts_max} = $ts->{max}; } elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) { + # Avoid scientific notation in the metrics by forcing it to use + # six decimal places. for my $value ( values %{$metrics{$attrib}} ) { next unless $value; - $value = sprintf '%.7f', $value; + $value = sprintf '%.6f', $value; + } + # ..except for the percentage, which only needs two + if ( my $pct = $metrics{$attrib}->{pct} ) { + $metrics{$attrib}->{pct} = sprintf('%.2f', $pct); } } } - push @queries, { class => \%class, attributes => \%metrics,