mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 05:29:30 +00:00
Fixed the precisions for numbers in the json output
This commit is contained in:
@@ -8049,11 +8049,13 @@ override query_report => sub {
|
|||||||
elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) {
|
elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) {
|
||||||
for my $value ( values %{$metrics{$attrib}} ) {
|
for my $value ( values %{$metrics{$attrib}} ) {
|
||||||
next unless $value;
|
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, {
|
push @queries, {
|
||||||
class => \%class,
|
class => \%class,
|
||||||
attributes => \%metrics,
|
attributes => \%metrics,
|
||||||
|
@@ -71,13 +71,18 @@ override query_report => sub {
|
|||||||
$class{ts_max} = $ts->{max};
|
$class{ts_max} = $ts->{max};
|
||||||
}
|
}
|
||||||
elsif ( ($ea->{type_for}->{$attrib} || '') eq 'num' ) {
|
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}} ) {
|
for my $value ( values %{$metrics{$attrib}} ) {
|
||||||
next unless $value;
|
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, {
|
push @queries, {
|
||||||
class => \%class,
|
class => \%class,
|
||||||
attributes => \%metrics,
|
attributes => \%metrics,
|
||||||
|
Reference in New Issue
Block a user