| 1 | package DBIx::OpenTracing; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use feature qw[ state ]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use syntax 'maybe'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use B; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Carp qw[ croak ]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use DBI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use DBIx::OpenTracing::Constants ':ALL'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use List::Util qw[ sum ]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use OpenTracing::GlobalTracer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use Package::Constants; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use Scalar::Util qw[ blessed looks_like_number ]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use Scope::Context; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | our $VERSION = 'v0.0.8'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | ▶ | use constant TAGS_DEFAULT => (DB_TAG_TYPE ,=> 'sql'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | use constant { | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | _DBI_EXECUTE => \&DBI::st::execute, | |||||||||||||||||||||||||||||||||||||||||
| 22 | _DBI_DO => \&DBI::db::do, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | _DBI_SELECTROW_ARRAY => \&DBI::db::selectrow_array, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | _DBI_SELECTROW_ARRAYREF => \&DBI::db::selectrow_arrayref, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | _DBI_SELECTROW_HASHREF => \&DBI::db::selectrow_hashref, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | _DBI_SELECTALL_ARRAYREF => \&DBI::db::selectall_arrayref, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | _DBI_SELECTALL_ARRAY => \&DBI::db::selectall_array, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | _DBI_SELECTROW_ARRAY => \&DBI::db::selectrow_array, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | _DBI_SELECTALL_HASHREF => \&DBI::db::selectall_hashref, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | _DBI_SELECTCOL_ARRAYREF => \&DBI::db::selectcol_arrayref, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 7 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | if (%DBIx::QueryLog::SKIP_PKG_MAP) { # hide from DBIx::QueryLog's caller() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $DBIx::QueryLog::SKIP_PKG_MAP{ (__PACKAGE__) } = 1; | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | our $is_currently_traced; # lexicals can't be localized | |||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | my ($is_enabled, $is_suspended); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 31 | ▶ | sub _numeric_result { 0+ $_[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_numeric_result: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 12 | ▶ | sub _sum_elements { looks_like_number($_[0]) ? $_[0] : 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sum_elements: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 68 | ▶ | sub _array_size { scalar @{ $_[0] } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_array_size: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 10 | ▶ | sub _hash_key_count { scalar keys %{ $_[0] } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hash_key_count: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # signature processors statement, bind values | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 157 | ▶ | sub _sig_dbh_stmt_attr_bind { @_[ 1, 3 .. $#_ ] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sig_dbh_stmt_attr_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 10 | ▶ | sub _sig_dbh_stmt_key_attr_bind { @_[ 1, 4 .. $#_ ] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sig_dbh_stmt_key_attr_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | ▶ | sub _sig_sth_bind { @_[ 0, 1 .. $#_ ] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sig_sth_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | sub enable { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 29 | ▶ | return if $is_enabled or $is_suspended; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
Condition100%3/3
$is_enabled or $is_suspended
MC/DC100%2/2
$is_enabled or $is_suspended
$is_enabled
$is_suspended
Truth table100%3/3
A or B
A= $is_enabledB= $is_suspended
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | state $execute = _gen_wrapper(_DBI_EXECUTE, { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | signature => \&_sig_sth_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | row_counter => \&_numeric_result, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | count_condition => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 10 | ▶ | my ($sth) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 10 | my $fields = $sth->{NUM_OF_FIELDS}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 10 | ▶ | return !defined $fields || $fields == 0; # non-select | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
!defined($fields) || $fields == 0
MC/DC50%1/2
!defined($fields) || $fields == 0
!defined($fields)
$fields == 0
Truth table66%2/3
not(A) || B
A= !defined($fields)B= $fields == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 23 | }); | |||||||||||||||||||||||||||||||||||||||||
| 62 | 23 | *DBI::st::execute = $execute; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 23 | state $do = _gen_wrapper(_DBI_DO, { | |||||||||||||||||||||||||||||||||||||||||
| 65 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | row_counter => \&_numeric_result, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 23 | *DBI::db::do = $do; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 23 | state $selectall_array = _gen_wrapper(_DBI_SELECTALL_ARRAY, { | |||||||||||||||||||||||||||||||||||||||||
| 71 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | row_counter => \&_sum_elements | ||||||||||||||||||||||||||||||||||||||||||
| 73 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 23 | *DBI::db::selectall_array = $selectall_array; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 23 | state $selectall_arrayref = _gen_wrapper(_DBI_SELECTALL_ARRAYREF, { | |||||||||||||||||||||||||||||||||||||||||
| 77 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | row_counter => \&_array_size | ||||||||||||||||||||||||||||||||||||||||||
| 79 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | *DBI::db::selectall_arrayref = $selectall_arrayref; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 23 | state $selectcol_arrayref = _gen_wrapper(_DBI_SELECTCOL_ARRAYREF, { | |||||||||||||||||||||||||||||||||||||||||
| 83 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | row_counter => \&_array_size, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 23 | *DBI::db::selectcol_arrayref = $selectcol_arrayref; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 23 | state $selectrow_array = _gen_wrapper(_DBI_SELECTROW_ARRAY, { | |||||||||||||||||||||||||||||||||||||||||
| 89 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 23 | *DBI::db::selectrow_array = $selectrow_array; | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 23 | state $selectrow_arrayref = _gen_wrapper(_DBI_SELECTROW_ARRAYREF, { | |||||||||||||||||||||||||||||||||||||||||
| 94 | signature => \&_sig_dbh_stmt_attr_bind | ||||||||||||||||||||||||||||||||||||||||||
| 95 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 23 | *DBI::db::selectrow_arrayref = $selectrow_arrayref; | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 23 | state $selectall_hashref = _gen_wrapper(_DBI_SELECTALL_HASHREF, { | |||||||||||||||||||||||||||||||||||||||||
| 99 | signature => \&_sig_dbh_stmt_key_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | row_counter => \&_hash_key_count, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 23 | *DBI::db::selectall_hashref = $selectall_hashref; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 23 | state $selectrow_hashref = _gen_wrapper(_DBI_SELECTROW_HASHREF, { | |||||||||||||||||||||||||||||||||||||||||
| 105 | signature => \&_sig_dbh_stmt_attr_bind, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 23 | *DBI::db::selectrow_hashref = $selectrow_hashref; | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 23 | $is_enabled = 1; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub disable { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 20 | ▶ | return unless $is_enabled; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 7 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 16 | *DBI::st::execute = _DBI_EXECUTE; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 16 | *DBI::db::do = _DBI_DO; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 16 | *DBI::db::selectall_array = _DBI_SELECTALL_ARRAY; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | *DBI::db::selectall_arrayref = _DBI_SELECTALL_ARRAYREF; | |||||||||||||||||||||||||||||||||||||||||
| 122 | 16 | *DBI::db::selectcol_arrayref = _DBI_SELECTCOL_ARRAYREF; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | *DBI::db::selectrow_array = _DBI_SELECTROW_ARRAY; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 16 | *DBI::db::selectrow_arrayref = _DBI_SELECTROW_ARRAYREF; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 16 | *DBI::db::selectall_hashref = _DBI_SELECTALL_HASHREF; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 16 | *DBI::db::selectrow_hashref = _DBI_SELECTROW_HASHREF; | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | $is_enabled = 0; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 16 | return; | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 7 | ▶ | my ($class, $tag_mode) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 7 | enable(); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 7 | ▶ | return if not defined $tag_mode; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | my @sensitive_tags = ( | |||||||||||||||||||||||||||||||||||||||||
| 140 | DB_TAG_SQL, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | DB_TAG_BIND, | ||||||||||||||||||||||||||||||||||||||||||
| 142 | DB_TAG_USER, | ||||||||||||||||||||||||||||||||||||||||||
| 143 | DB_TAG_DBNAME, | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | ▶ | if ($tag_mode eq '-none') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | $class->hide_tags(DB_TAGS_ALL); | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | elsif ($tag_mode eq '-safe') { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $class->hide_tags(@sensitive_tags); | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | elsif ($tag_mode eq '-secure') { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $class->_disable_tags(@sensitive_tags); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | croak "Unknown mode: $tag_mode"; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub unimport { disable() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unimport: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | sub _tags_dbh { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 187 | ▶ | my ($dbh) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tags_dbh: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 187 | ▶ | return if !blessed($dbh) or !$dbh->isa('DBI::db'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($dbh) and $dbh->isa("DBI::db")
MC/DC50%1/2
builtin::blessed($dbh) and $dbh->isa("DBI::db")
builtin::blessed($dbh)
$dbh->isa("DBI::db")
Truth table66%2/3
A and B
A= builtin::blessed($dbh)B= $dbh->isa("DBI::db")
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 177 | my $dbname = $dbh->{Name}; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 177 | ▶ | $dbname = $1 if $dbname =~ /dbname=([^;]+);/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 171 | maybe DB_TAG_USER ,=> $dbh->{Username}, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 177 | maybe DB_TAG_DBNAME ,=> $dbname, | |||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub _tags_sth { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 177 | ▶ | my ($sth) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tags_sth: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 177 | my (%tags, $sql); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 177 | ▶ | if (!blessed($sth) or !$sth->isa('DBI::st')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($sth) && $sth->isa('DBI::st')
MC/DC50%1/2
builtin::blessed($sth) && $sth->isa('DBI::st')
builtin::blessed($sth)
$sth->isa('DBI::st')
Truth table66%2/3
A && B
A= builtin::blessed($sth)B= $sth->isa('DBI::st')
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 167 | $sql = "$sth"; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 10 | %tags = _tags_dbh($sth->{Database}); | |||||||||||||||||||||||||||||||||||||||||
| 184 | 10 | $sql = $sth->{Statement}; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 177 | $sql = _remove_sql_comments($sql); | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 177 | $tags{ (DB_TAG_SQL) } = $sql; | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 177 | ▶ | if (my $summary = _gen_sql_summary($sql)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 157 | $tags{ (DB_TAG_SQL_SUMMARY) } = $summary; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 177 | return %tags; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | sub _remove_sql_comments { # TODO: support engine-specific syntax properly | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 177 | ▶ | my ($sql) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_sql_comments: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 177 | $sql =~ s{ | |||||||||||||||||||||||||||||||||||||||||
| 201 | (?> # skip over strings and quoted table names | ||||||||||||||||||||||||||||||||||||||||||
| 202 | (['"`]) # opening quote | ||||||||||||||||||||||||||||||||||||||||||
| 203 | .*? | ||||||||||||||||||||||||||||||||||||||||||
| 204 | (?<!\\)(?:\\{2})* # make sure the closing quote is not escaped | ||||||||||||||||||||||||||||||||||||||||||
| 205 | \1 # closing quote | ||||||||||||||||||||||||||||||||||||||||||
| 206 | )? \K | ||||||||||||||||||||||||||||||||||||||||||
| 207 | | \#.*?$ # hash until end of line | ||||||||||||||||||||||||||||||||||||||||||
| 208 | | --.*?$ # double-dash until end of line | ||||||||||||||||||||||||||||||||||||||||||
| 209 | | /\* (?s).*? \*/ # multi-line C-style comment | ||||||||||||||||||||||||||||||||||||||||||
| 210 | }{}gmx; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 177 | return $sql; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | sub _gen_sql_summary { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 177 | ▶ | my ($sql) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_sql_summary: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # comments are removed, so the first occurence should be the keyword | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 177 | my ($type) = $sql =~ /\b( | |||||||||||||||||||||||||||||||||||||||||
| 220 | insert | select | update | ||||||||||||||||||||||||||||||||||||||||||
| 221 | | delete | truncate | show | ||||||||||||||||||||||||||||||||||||||||||
| 222 | | alter | create | drop | ||||||||||||||||||||||||||||||||||||||||||
| 223 | )/ix; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 177 | ▶ | return if not $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 157 | my $table = '...'; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 157 | ▶ | if ($sql =~ m{(?:from|into|update|truncate|drop|alter|table)\s+(`?)(\w+)\1}i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 113 | $table = $2; | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 157 | return uc($type) . ": $table"; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | sub _tags_bind_values { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 177 | ▶ | my ($bind_ref) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tags_bind_values: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 177 | ▶ | return if not @$bind_ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 50 | ▶ | my $bind_str = join ',', map { defined $_ ? "`$_`" : 'undef' } @$bind_ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 50 | return (DB_TAG_BIND ,=> $bind_str); | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | sub _tags_caller { | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 177 | ▶ | my ($call_package, $call_filename, $call_line) = caller(1); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tags_caller: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 177 | my $call_sub = (caller(2))[3]; | |||||||||||||||||||||||||||||||||||||||||
| 244 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 177 | maybe | |||||||||||||||||||||||||||||||||||||||||
| 246 | DB_TAG_CALLER_SUB ,=> $call_sub, | ||||||||||||||||||||||||||||||||||||||||||
| 247 | DB_TAG_CALLER_FILE ,=> $call_filename, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | DB_TAG_CALLER_LINE ,=> $call_line, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | DB_TAG_CALLER_PACKAGE ,=> $call_package, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | my (%hidden_tags, %disabled_tags); | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | sub _filter_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 296 | ▶ | my ($tags) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_tags: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 296 | delete @$tags{ keys %disabled_tags, keys %hidden_tags }; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 296 | return $tags; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | sub _tag_enabled { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 119 | ▶ | my ($tag) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_enabled: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 119 | return !!_filter_tags({ $tag => 1 })->{$tag}; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | sub hide_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 26 | ▶ | my ($class, @tags) = @_;; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hide_tags: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 26 | ▶ | return if not @tags; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 20 | undef @hidden_tags{@tags}; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | sub show_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 31 | ▶ | my ($class, @tags) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_tags: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 31 | ▶ | return if not @tags; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 25 | delete @hidden_tags{@tags}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | sub hide_tags_temporarily { | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hide_tags_temporarily: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | my @tags = grep { not exists $hidden_tags{$_} } @_; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | $class->hide_tags(@tags); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 8 | ▶ | Scope::Context->up->reap(sub { $class->show_tags(@tags) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub show_tags_temporarily { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 8 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show_tags_temporarily: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | my @tags = grep { exists $hidden_tags{$_} } @_; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 8 | $class->show_tags(@tags); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | ▶ | Scope::Context->up->reap(sub { $class->hide_tags(@tags) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | sub _disable_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | my ($class, @tags) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_disable_tags: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | undef @disabled_tags{@tags}; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | sub _enable_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 2 | ▶ | my ($class, @tags) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_enable_tags: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | delete @disabled_tags{@tags}; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | sub disable_tags { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_tags: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | my @tags = grep { not exists $disabled_tags{$_} } @_; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 2 | $class->_disable_tags(@tags); | |||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | Scope::Context->up->reap(sub { $class->_enable_tags(@tags) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 7 | sub _add_tag { | |||||||||||||||||||||||||||||||||||||||||
| 318 | 119 | ▶ | my ($span, $tag, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_tag: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 119 | ▶ | return unless _tag_enabled($tag); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 117 | $span->add_tag($tag => $value); | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | sub _gen_wrapper { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 63 | ▶ | my ($method, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_wrapper: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 63 | my $row_counter = $args->{row_counter}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 63 | my $sig_processor = $args->{signature}; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 63 | my $count_condition = $args->{count_condition}; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 63 | my $method_name = B::svref_2object($method)->GV->NAME; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | my $can_count_rows = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 157 | ▶ | defined $row_counter | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition100%6/6
defined $row_counter && (!defined($count_condition) || &$count_condition(@_))
not defined $count_condition or &$count_condition(@_)
MC/DC100%3/3
defined $row_counter && (!defined($count_condition) || &$count_condition(@_))
defined $row_counter
not defined $count_condition
&$count_condition(@_)
Truth table100%4/4
A && not(B) or C
A= defined $row_counterB= not defined $count_conditionC= &$count_condition(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | and | ||||||||||||||||||||||||||||||||||||||||||
| 333 | !defined $count_condition || $count_condition->(@_) | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 63 | }; | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 288 | ▶ | goto $method if $is_currently_traced; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 177 | local $is_currently_traced = 1; | |||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 177 | my ($statement, @bind) = $sig_processor->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 177 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 177 | my $tracer = OpenTracing::GlobalTracer->get_global_tracer(); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 177 | my $scope = $tracer->start_active_span( | |||||||||||||||||||||||||||||||||||||||||
| 345 | "dbi_$method_name", | ||||||||||||||||||||||||||||||||||||||||||
| 346 | tags => _filter_tags({ | ||||||||||||||||||||||||||||||||||||||||||
| 347 | TAGS_DEFAULT, | ||||||||||||||||||||||||||||||||||||||||||
| 348 | _tags_sth($statement), | ||||||||||||||||||||||||||||||||||||||||||
| 349 | _tags_dbh($handle), | ||||||||||||||||||||||||||||||||||||||||||
| 350 | _tags_bind_values(\@bind), | ||||||||||||||||||||||||||||||||||||||||||
| 351 | _tags_caller(), | ||||||||||||||||||||||||||||||||||||||||||
| 352 | }), | ||||||||||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 177 | my $span = $scope->get_span(); | |||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 177 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 177 | my $wantarray = wantarray; # eval has its own | |||||||||||||||||||||||||||||||||||||||||
| 358 | 177 | my $failed = !eval { | |||||||||||||||||||||||||||||||||||||||||
| 359 | 177 | ▶ | if ($wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 20 | $result = [ $handle->$method(@_) ]; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 157 | $result = $handle->$method(@_); | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 167 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 366 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 177 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 177 | ▶ | if ($failed or defined $handle->err) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$failed or defined $handle->err
MC/DC100%2/2
$failed or defined $handle->err
$failed
defined $handle->err
Truth table100%3/3
A or B
A= $failedB= defined $handle->err
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 20 | $span->add_tag(error => 1); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | elsif ($can_count_rows->($handle)) { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 119 | ▶ | my $rows = sum(map { $row_counter->($_) } $wantarray ? @$result : $result); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 119 | _add_tag($span, DB_TAG_ROWS,=> $rows); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 177 | $scope->close(); | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 177 | ▶ | die $error if $failed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 167 | ▶ | return $wantarray ? @$result : $result; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 63 | } | |||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub enable_temporarily { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 8 | ▶ | return if $is_enabled; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_temporarily: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 6 | enable(); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | Scope::Context->up->reap(\&disable); | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | sub disable_temporarily { | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 8 | ▶ | return unless $is_enabled; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_temporarily: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 4 | disable(); | |||||||||||||||||||||||||||||||||||||||||
| 394 | 4 | Scope::Context->up->reap(\&enable); | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | sub suspend { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | ▶ | return if $is_suspended; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
suspend: called CC=2 SCAR=7.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 2 | my $was_enabled = $is_enabled; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 2 | disable(); | |||||||||||||||||||||||||||||||||||||||||
| 402 | 2 | $is_suspended = 1; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 2 | ▶ | Scope::Context->up->reap(sub { $is_suspended = 0; enable() if $was_enabled }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||