[Rt-commit] rt branch, query-logging, updated. rt-3.8.8-930-g0d20f31
Shawn Moore
sartak at bestpractical.com
Tue Sep 28 17:25:38 EDT 2010
The branch, query-logging has been updated
via 0d20f312e599c11e6b5e9bc452d3c4486e20126c (commit)
via 3a382874df9e4edee4467d37c893499d913eb2b7 (commit)
from dd62591258b0329781a6d950f693404d907f85e6 (commit)
Summary of changes:
lib/RT/Handle.pm | 29 +++++++++++++++++++++++++++++
lib/RT/Interface/Web.pm | 12 +++++++++++-
2 files changed, 40 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 3a382874df9e4edee4467d37c893499d913eb2b7
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Sep 28 17:24:12 2010 -0400
Keep track of SQL query history on the RT::Handle object
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index b183dea..3cdecd8 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1058,6 +1058,31 @@ sub ACLEquivGroupId {
return $equiv_group->Id;
}
+=head2 QueryHistory
+
+Returns the SQL query history associated with this handle. The top level array
+represents a lists of request. Each request is a hash with metadata about the
+request (such as the URL) and a list of queries. You'll probably not be using this.
+
+=cut
+
+sub QueryHistory {
+ my $self = shift;
+
+ return $self->{QueryHistory};
+}
+
+=head2 AddRequestToHistory
+
+=cut
+
+sub AddRequestToHistory {
+ my $self = shift;
+ my $request = shift;
+
+ push @{ $self->{QueryHistory} }, $request;
+}
+
__PACKAGE__->FinalizeDatabaseType;
RT::Base->_ImportOverlays();
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index f95b9c0..07eb896 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -217,7 +217,9 @@ sub HandleRequest {
$HTML::Mason::Commands::m->callback( %$ARGS, CallbackName => 'Default', CallbackPage => '/autohandler' );
ShowRequestedPage($ARGS);
- LogRecordedSQLStatements();
+ LogRecordedSQLStatements(RequestData => {
+ Path => $HTML::Mason::Commands::m->request_comp->path,
+ });
# Process per-page final cleanup callbacks
$HTML::Mason::Commands::m->callback( %$ARGS, CallbackName => 'Final', CallbackPage => '/autohandler' );
@@ -769,12 +771,20 @@ sub MaybeEnableSQLStatementLog {
}
sub LogRecordedSQLStatements {
+ my %args = @_;
+
my $log_sql_statements = RT->Config->Get('StatementLog');
return unless ($log_sql_statements);
my @log = $RT::Handle->SQLStatementLog;
$RT::Handle->ClearSQLStatementLog;
+
+ $RT::Handle->AddRequestToHistory({
+ %{ $args{RequestData} },
+ Queries => \@log,
+ });
+
for my $stmt (@log) {
my ( $time, $sql, $bind, $duration ) = @{$stmt};
my @bind;
commit 0d20f312e599c11e6b5e9bc452d3c4486e20126c
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Sep 28 17:26:16 2010 -0400
Missing POD
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 3cdecd8..e5af419 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -1074,6 +1074,10 @@ sub QueryHistory {
=head2 AddRequestToHistory
+Adds a web request to the query history. It must be a hash with keys Path (a
+string) and Queries (an array reference of arrays, where elements are time,
+sql, bind parameters, and duration).
+
=cut
sub AddRequestToHistory {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list