Agent/Monitors/DBI.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« Agent/Output.pm ↑ Summary Agent/Frameworks/CGI.pm »
1 package PerlGuard::Agent::Monitors::DBI;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=2.6
4 use PerlGuard::Agent::Monitors::DBI::Tracer;
5 use Scalar::Util qw(blessed);
6  
7 extends 'PerlGuard::Agent::Monitors';
8  
9 has tracer => ( is => 'rw' );
10  
11 sub start_monitoring {
12 my $self = shift;
13  
14 #my $handle;
15 #open ($handle,'>>','/tmp/dbi') or die("Cant open /tmp/dbi");
16 #print $handle "\n * \n * \n * \n * \n";
17 #use Data::Dumper;
18  
19 my $tracer = PerlGuard::Agent::Monitors::DBI::Tracer->new(
20 sub {
21 my %args = @_;
22  
23 unless(blessed($self->agent)) {
24 #warn "Agent was not a blessed object in DBI monitor";
25 #print $handle Dumper \%args;
26  
27 return;
28 }
29  
30 $self->agent->add_database_transaction({
31 start_time => $args{start},
32 finish_time => $args{finish},
33 query => $args{sql},
34 rows_returned => $args{rows}
35 });
36 }
37 );
38  
39 $self->tracer($tracer);
40  
41 }
42  
43 sub stop_monitoring {
44 my $self = shift;
45  
46 $self->tracer(undef);
47 }
48  
49 1;
« Agent/Output.pm ↑ Summary Agent/Frameworks/CGI.pm »