QueryReportFormatter is used primarily by mk-query-digest to print reports. The main sub is print_reports() which prints the various reports for mk-query-digest --report-format. Each report is produced in a sub of the same name; e.g. --report-format=query_report == sub query_report(). The given ea (EventAggregator object) is expected to be “complete”; i.e. fully aggregated and $ea->calculate_statistical_metrics() already called. Subreports “profile” and “prepared” require the ReportFormatter module, which is also in mk-query-digest.
QueryReportFormatter | QueryReportFormatter is used primarily by mk-query-digest to print reports. |
Functions | |
new | |
set_report_formatter | Set a report formatter object for a report. |
print_reports | |
rusage | |
date | |
hostname | |
files | |
header | |
query_report | |
event_report | |
chart_distro | |
distro_sparkline | Make a sparkline of the chart_distro() graph. |
profile | |
prepared | |
make_global_header | |
make_event_header | |
make_label | |
bool_percents | |
format_string_list | |
sort_attribs | |
pref_sort | |
tables_report | |
explain_report | |
format_time_range | |
explain_sparkline | |
_d |
sub new
%args | Required arguments |
OptionParser | OptionParser object |
QueryRewriter | QueryRewriter object |
Quoter | Quoter object |
QueryReview | QueryReview object used in query_report() |
dbh | dbh used in explain_report() |
ExplainAnalyzer | ExplainAnalyzer object used in explain_report(). This causes a sparkline to be printed (issue 1141). |
QueryReportFormatter object
sub set_report_formatter
Set a report formatter object for a report. By default this package will instantiate ReportFormatter objects to format columnized reports (e.g. for profile and prepared reports). Setting a caller-created formatter object (usually a ReportFormatter obj) is used for tested and also by <mk-query-digest> to extend the profile report line width to 82 for the --explain sparkline.
%args | Arguments |
report | Report name, e.g. profile, prepared, etc. |
formatter | Formatter object, usually a ReportFormatter obj |
sub distro_sparkline
Make a sparkline of the chart_distro() graph. The following character codes are used: _.-^ If a bucket doesn’t have a value, a space is used. So _ buckets are the lowest lines on the full graph (chart_distro()), and ^ are the peaks on the full graph. See QueryReportFormatter.t for several examples.
This sub isn’t the most optimized. The first half is the same code as chart_distro(). Then the latter code, unique to this sub, essentially compresses the full chart further into 8 characters using the 4 char codes above.
%args | Arguments |
ea | EventAggregator object |
item | Item in results to chart |
attrib | Attribute of item to chart |
Sparkchart string
sub new
Set a report formatter object for a report.
sub set_report_formatter
sub print_reports
sub rusage
sub date
sub hostname
sub files
sub header
sub query_report
sub event_report
sub chart_distro
Make a sparkline of the chart_distro() graph.
sub distro_sparkline
sub profile
sub prepared
sub make_global_header
sub make_event_header
sub make_label
sub bool_percents
sub format_string_list
sub sort_attribs
sub pref_sort
sub tables_report
sub explain_report
sub format_time_range
sub explain_sparkline
sub _d