mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 12:58:45 +00:00
PT-243 added --max-hostname-length & max-line-length to pt-query-digest
This commit is contained in:
@@ -6745,6 +6745,12 @@ sub BUILDARGS {
|
||||
ts => 1,
|
||||
},
|
||||
};
|
||||
if (!defined($self->{max_hostname_length})) {
|
||||
$self->{max_hostname_length} = MAX_STRING_LENGTH;
|
||||
}
|
||||
if (!defined($self->{max_line_length})) {
|
||||
$self->{max_line_length} = LINE_LENGTH;
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
||||
@@ -7613,16 +7619,19 @@ sub format_string_list {
|
||||
if ( $str =~ m/(?:\d+\.){3}\d+/ ) {
|
||||
$print_str = $str; # Do not shorten IP addresses.
|
||||
}
|
||||
elsif ( length $str > MAX_STRING_LENGTH ) {
|
||||
$print_str = substr($str, 0, MAX_STRING_LENGTH) . '...';
|
||||
}
|
||||
else {
|
||||
elsif ( $self->{max_hostname_length} > 0 and length $str > $self->{max_hostname_length} ) {
|
||||
$print_str = substr($str, 0, $self->{max_hostname_length}) . '...';
|
||||
} else {
|
||||
$print_str = $str;
|
||||
}
|
||||
my $p = percentage_of($cnt_for->{$str}, $class_cnt);
|
||||
$print_str .= " ($cnt_for->{$str}/$p%)";
|
||||
if ( !$show_all->{$attrib} ) {
|
||||
last if (length $line) + (length $print_str) > LINE_LENGTH - 27;
|
||||
my $trim_length = LINE_LENGTH;
|
||||
if ($self->{max_hostname_length} == 0 or $self->{max_hostname_length} > LINE_LENGTH) {
|
||||
$trim_length = $self->{max_hostname_length};
|
||||
}
|
||||
if ( $self->{max_line_length} > 0 and !$show_all->{$attrib} ) {
|
||||
last if (length $line) + (length $print_str) > $self->{max_line_length} - 27;
|
||||
}
|
||||
$line .= "$print_str, ";
|
||||
$i++;
|
||||
@@ -14522,13 +14531,15 @@ sub print_reports {
|
||||
? 'JSONReportFormatter'
|
||||
: 'QueryReportFormatter';
|
||||
my $qrf = $report_class->new(
|
||||
dbh => $ep_dbh,
|
||||
QueryReview => $args{QueryReview},
|
||||
QueryRewriter => $args{QueryRewriter},
|
||||
OptionParser => $args{OptionParser},
|
||||
QueryParser => $args{QueryParser},
|
||||
Quoter => $args{Quoter},
|
||||
show_all => $show_all,
|
||||
dbh => $ep_dbh,
|
||||
QueryReview => $args{QueryReview},
|
||||
QueryRewriter => $args{QueryRewriter},
|
||||
OptionParser => $args{OptionParser},
|
||||
QueryParser => $args{QueryParser},
|
||||
Quoter => $args{Quoter},
|
||||
show_all => $show_all,
|
||||
max_hostname_length => $o->get('max-hostname-length'),
|
||||
max_line_length => $o->get('max-line-length'),
|
||||
);
|
||||
|
||||
$qrf->print_reports(
|
||||
@@ -15921,6 +15932,18 @@ type: string
|
||||
|
||||
Print all output to this file when daemonized.
|
||||
|
||||
=item --max-hostname-length
|
||||
|
||||
type: int; default: 10
|
||||
|
||||
Trim host names in reports to this length. 0=Do not trim host names.
|
||||
|
||||
=item --max-line-length
|
||||
|
||||
type: int; default: 74
|
||||
|
||||
Trim lines to this length. 0=Do not trim lines.
|
||||
|
||||
=item --order-by
|
||||
|
||||
type: Array; default: Query_time:sum
|
||||
|
Reference in New Issue
Block a user