mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-18 09:43:09 +00:00
PT-243 added --max-hostname-length & max-line-length to pt-query-digest
This commit is contained in:
@@ -881,6 +881,84 @@ ok(
|
||||
"IPs not shortened with more"
|
||||
);
|
||||
|
||||
# Don't shorten hostnames
|
||||
$events = [
|
||||
{
|
||||
cmd => 'Query',
|
||||
arg => "foo",
|
||||
Query_time => '8.000652',
|
||||
host => 'a-really-long-host-name',
|
||||
},
|
||||
{
|
||||
cmd => 'Query',
|
||||
arg => "foo",
|
||||
Query_time => '8.000652',
|
||||
host => '123.123.123.789',
|
||||
},
|
||||
];
|
||||
|
||||
$ea = new EventAggregator(
|
||||
groupby => 'arg',
|
||||
worst => 'Query_time',
|
||||
ignore_attributes => [qw(arg cmd)],
|
||||
);
|
||||
foreach my $event (@$events) {
|
||||
$ea->aggregate($event);
|
||||
}
|
||||
$ea->calculate_statistical_metrics();
|
||||
my $no_trim_qrf = new QueryReportFormatter(
|
||||
OptionParser => $o,
|
||||
QueryRewriter => $qr,
|
||||
QueryParser => $qp,
|
||||
Quoter => $q,
|
||||
ExplainAnalyzer => $ex,
|
||||
max_hostname_length => 0,
|
||||
);
|
||||
|
||||
$result = $no_trim_qrf->event_report(
|
||||
ea => $ea,
|
||||
select => [ qw(Query_time host) ],
|
||||
item => 'foo',
|
||||
rank => 1,
|
||||
orderby => 'Query_time',
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
$result,
|
||||
"t/lib/samples/QueryReportFormatter/report014_no_trim.txt",
|
||||
cmd_output => 1,
|
||||
),
|
||||
"Hostnames were not trimmed"
|
||||
);
|
||||
|
||||
$no_trim_qrf = new QueryReportFormatter(
|
||||
OptionParser => $o,
|
||||
QueryRewriter => $qr,
|
||||
QueryParser => $qp,
|
||||
Quoter => $q,
|
||||
ExplainAnalyzer => $ex,
|
||||
max_hostname_length => 12,
|
||||
max_line_length => 200,
|
||||
);
|
||||
|
||||
$result = $no_trim_qrf->event_report(
|
||||
ea => $ea,
|
||||
select => [ qw(Query_time host) ],
|
||||
item => 'foo',
|
||||
rank => 1,
|
||||
orderby => 'Query_time',
|
||||
);
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
$result,
|
||||
"t/lib/samples/QueryReportFormatter/report014_trim_12.txt",
|
||||
cmd_output => 1,
|
||||
),
|
||||
"Hostnames were not trimmed"
|
||||
);
|
||||
|
||||
$result = $qrf->event_report(
|
||||
ea => $ea,
|
||||
select => [ qw(Query_time host) ],
|
||||
|
8
t/lib/samples/QueryReportFormatter/report014_no_trim.txt
Normal file
8
t/lib/samples/QueryReportFormatter/report014_no_trim.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
# Item 1: 0 QPS, 0x concurrency, ID 0xEDEF654FCCC4A4D8 at byte 0 _________
|
||||
# Scores: V/M = 0.00
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 100 2
|
||||
# Exec time 100 16s 8s 8s 8s 8s 0 8s
|
||||
# String:
|
||||
# Hosts 123.123.123.789 (1/50%)... 1 more
|
8
t/lib/samples/QueryReportFormatter/report014_trim_12.txt
Normal file
8
t/lib/samples/QueryReportFormatter/report014_trim_12.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
# Item 1: 0 QPS, 0x concurrency, ID 0xEDEF654FCCC4A4D8 at byte 0 _________
|
||||
# Scores: V/M = 0.00
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 100 2
|
||||
# Exec time 100 16s 8s 8s 8s 8s 0 8s
|
||||
# String:
|
||||
# Hosts 123.123.123.789 (1/50%), a-really-lon... (1/50%)
|
@@ -2,7 +2,7 @@
|
||||
# Scores: V/M = 0.00
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 100 3
|
||||
# Exec time 100 24s 8s 8s 8s 8s 0 8s
|
||||
# Count 100 2
|
||||
# Exec time 100 16s 8s 8s 8s 8s 0 8s
|
||||
# String:
|
||||
# Hosts 123.123.123.456 (1/33%)... 2 more
|
||||
# Hosts 123.123.123.789 (1/50%), a-really-l... (1/50%)
|
||||
|
16
t/lib/samples/slowlogs/slow-pt-243.txt
Normal file
16
t/lib/samples/slowlogs/slow-pt-243.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
/usr/sbin/mysqld, Version: 5.0.77-percona-b13-log (MySQL Percona Edition (GPL)). started with:
|
||||
Tcp port: 3306 Unix socket: /var/run/mysqld/mysqld.sock
|
||||
Time Id Command Argument
|
||||
# Time: 090311 18:11:50
|
||||
# User@Host: root[root] @ alonghotnamelikelocalhost []
|
||||
# Thread_id: 47 Schema:
|
||||
# Query_time: 0.017850 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 Rows_affected: 0 Rows_read: 0
|
||||
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
|
||||
# Filesort: No Filesort_on_disk: No Merge_passes: 0
|
||||
# administrator command: Refresh;
|
||||
# User@Host: root[root] @ alonghotnamelikelocalhost []
|
||||
# Thread_id: 47 Schema:
|
||||
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 Rows_affected: 0 Rows_read: 0
|
||||
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
|
||||
# Filesort: No Filesort_on_disk: No Merge_passes: 0
|
||||
# administrator command: Quit;
|
Reference in New Issue
Block a user