Author: timbo
Date: Wed Mar 21 15:26:52 2007
New Revision: 9293

Modified:
   dbi/trunk/lib/DBI/Gofer/Execute.pm
   dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm

Log:
Add more stats.


Modified: dbi/trunk/lib/DBI/Gofer/Execute.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Execute.pm  (original)
+++ dbi/trunk/lib/DBI/Gofer/Execute.pm  Wed Mar 21 15:26:52 2007
@@ -242,7 +242,7 @@
         $dbh = $self->_connect($request);
         my $args = $request->dbh_method_call; # [ 'method_name', @args ]
         my $meth = shift @$args;
-        $stats->{dbh_method_calls}->{$meth}++;
+        $stats->{method_calls_dbh}->{$meth}++;
         my @rv = ($request->dbh_wantarray)
             ?        $dbh->$meth(@$args)
             : scalar $dbh->$meth(@$args);
@@ -269,7 +269,7 @@
     }
 
     if ($rv_ref and my $lid_args = $request->dbh_last_insert_id_args) {
-        $stats->{dbh_method_calls}->{last_insert_id}++;
+        $stats->{method_calls_dbh}->{last_insert_id}++;
         my $id = $dbh->last_insert_id( @$lid_args );
         $response->last_insert_id( $id );
     }
@@ -322,7 +322,7 @@
 
         my $args = $request->dbh_method_call; # [ 'method_name', @args ]
         my $meth = shift @$args;
-        $stats->{sth_method_calls}->{$meth}++;
+        $stats->{method_calls_sth}->{$meth}++;
         $sth = $dbh->$meth(@$args);
         my $last = '(sth)'; # a true value (don't try to return actual sth)
 
@@ -330,13 +330,13 @@
         if (my $calls = $request->sth_method_calls) {
             for my $meth_call (@$calls) {
                 my $method = shift @$meth_call;
-                $stats->{sth_method_calls}->{$method}++;
+                $stats->{method_calls_sth}->{$method}++;
                 $last = $sth->$method(@$meth_call);
             }
         }
 
         if (my $lid_args = $request->dbh_last_insert_id_args) {
-            $stats->{sth_method_calls}->{last_insert_id}++;
+            $stats->{method_calls_sth}->{last_insert_id}++;
             $last_insert_id = $dbh->last_insert_id( @$lid_args );
         }
 
@@ -384,13 +384,22 @@
                 for keys %$sth_result_attr;
         }
 
+        my $row_count = 0;
         my $rs_list = [];
         do {
             my $rs = $self->fetch_result_set($sth, $sth_attr);
             push @$rs_list, $rs;
+            if (my $rows = $rs->{rowset}) {
+                $row_count += @$rows;
+            }
         } while $sth->more_results
              || $sth->{syb_more_results};
 
+        my $stats = $self->{stats};
+        $stats->{rows_returned_total} += $row_count;
+        $stats->{rows_returned_max} = $row_count
+            if $row_count > ($stats->{rows_returned_max}||0);
+
         $rs_list;
     };
     $response->add_err(1, $@) if $@;

Modified: dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm       (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm       Wed Mar 21 15:26:52 2007
@@ -67,11 +67,17 @@
 
         my $frozen_response = $transport->freeze_data($response);
         print $frozen_response;
+
+        my $stats = $executor->{stats};
+        $stats->{frozen_request_max_bytes} = length($frozen_request)
+            if length($frozen_request) > 
($stats->{frozen_request_max_bytes}||0);
+        $stats->{frozen_response_max_bytes} = length($frozen_response)
+            if length($frozen_response) > 
($stats->{frozen_response_max_bytes}||0);
     };
     if ($@) {
         chomp $@;
         warn $@;
-        $r->custom_response(SERVER_ERROR, "$@ version $VERSION (DBI 
$DBI::VERSION) on $hostname");
+        $r->custom_response(SERVER_ERROR, "$@, version $VERSION (DBI 
$DBI::VERSION) on $hostname");
         return SERVER_ERROR;
     }
 

Reply via email to