| 1 | package Async::Redis::Telemetry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 92 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 92 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 92 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 92 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Commands with sensitive arguments that need redaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | our %REDACT_RULES = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | AUTH => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # AUTH password | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | return ('[REDACTED]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | elsif (@args >= 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # AUTH username password | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | return ($args[0], '[REDACTED]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | CONFIG => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | return @args unless @args >= 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my $subcommand = uc($args[0] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args[0] // ""
MC/DC0%0/1
$args[0] // ""
$args[0]
Truth table0%0/2
A
A= $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($subcommand eq 'SET') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $param = lc($args[1] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args[1] // ""
MC/DC0%0/1
$args[1] // ""
$args[1]
Truth table0%0/2
A
A= $args[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($param =~ /^(requirepass|masterauth|masteruser|user)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return ($args[0], $args[1], '[REDACTED]'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | MIGRATE => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | for (my $i = 0; $i <= $#args; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $arg = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $uc_arg = uc($arg // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg // ""
MC/DC0%0/1
$arg // ""
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($uc_arg eq 'AUTH' && defined $args[$i + 1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$uc_arg eq "AUTH" and defined $args[$i + 1]
MC/DC0%0/2
$uc_arg eq "AUTH" and defined $args[$i + 1]
$uc_arg eq "AUTH"
defined $args[$i + 1]
Truth table0%0/3
A and B
A= $uc_arg eq "AUTH"B= defined $args[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | push @result, $arg, '[REDACTED]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $i++; # Skip password | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ▶ | elsif ($uc_arg eq 'AUTH2' && defined $args[$i + 1] && defined $args[$i + 2]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$uc_arg eq "AUTH2" and defined $args[$i + 1] and defined $args[$i + 2]
$uc_arg eq "AUTH2" and defined $args[$i + 1]
MC/DC0%0/3
$uc_arg eq "AUTH2" and defined $args[$i + 1] and defined $args[$i + 2]
$uc_arg eq "AUTH2"
defined $args[$i + 1]
defined $args[$i + 2]
Truth table0%0/4
A and B and C
A= $uc_arg eq "AUTH2"B= defined $args[$i + 1]C= defined $args[$i + 2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | push @result, $arg, $args[$i + 1], '[REDACTED]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $i += 2; # Skip username and password | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | push @result, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | HELLO => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | for (my $i = 0; $i <= $#args; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $arg = $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $uc_arg = uc($arg // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg // ""
MC/DC0%0/1
$arg // ""
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ($uc_arg eq 'AUTH' && defined $args[$i + 1] && defined $args[$i + 2]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$uc_arg eq "AUTH" and defined $args[$i + 1] and defined $args[$i + 2]
$uc_arg eq "AUTH" and defined $args[$i + 1]
MC/DC0%0/3
$uc_arg eq "AUTH" and defined $args[$i + 1] and defined $args[$i + 2]
$uc_arg eq "AUTH"
defined $args[$i + 1]
defined $args[$i + 2]
Truth table0%0/4
A and B and C
A= $uc_arg eq "AUTH"B= defined $args[$i + 1]C= defined $args[$i + 2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | push @result, $arg, $args[$i + 1], '[REDACTED]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $i += 2; # Skip username and password | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | push @result, $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | ACL => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my (@args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | return @args unless @args >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | my $subcommand = uc($args[0] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args[0] // ""
MC/DC0%0/1
$args[0] // ""
$args[0]
Truth table0%0/2
A
A= $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($subcommand eq 'SETUSER' && @args >= 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$subcommand eq "SETUSER" and @args >= 3
MC/DC0%0/2
$subcommand eq "SETUSER" and @args >= 3
$subcommand eq "SETUSER"
@args >= 3
Truth table0%0/3
A and B
A= $subcommand eq "SETUSER"B= @args >= 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # ACL SETUSER username ...rules... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Redact any >password patterns | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my @result = ($args[0], $args[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | for my $i (2 .. $#args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($args[$i] =~ /^>/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | push @result, '>[REDACTED]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | push @result, $args[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | return @result; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | return @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 92 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # Format command for logging with redaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub format_command_for_log { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_command_for_log: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my (@cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return '' unless @cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my $name = uc($cmd[0] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cmd[0] // ""
MC/DC0%0/1
$cmd[0] // ""
$cmd[0]
Truth table0%0/2
A
A= $cmd[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my @args = @cmd[1 .. $#cmd]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if (my $redactor = $REDACT_RULES{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | @args = $redactor->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return join(' ', $name, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Format command for OTel span (same redaction, optional args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 3 | ▶ | sub format_command_for_span { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_command_for_span: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | my ($include_args, $redact, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | return '' unless @cmd; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | my $name = uc($cmd[0] // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cmd[0] // ""
MC/DC0%0/1
$cmd[0] // ""
$cmd[0]
Truth table50%1/2
A
A= $cmd[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | return $name unless $include_args; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | my @args = @cmd[1 .. $#cmd]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | ▶ | if ($redact && (my $redactor = $REDACT_RULES{$name})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$redact and my $redactor = $Async::Redis::Telemetry::REDACT_RULES{$name}
MC/DC50%1/2
$redact and my $redactor = $Async::Redis::Telemetry::REDACT_RULES{$name}
$redact
my $redactor = $Async::Redis::Telemetry::REDACT_RULES{$name}
Truth table66%2/3
A and B
A= $redactB= my $redactor = $Async::Redis::Telemetry::REDACT_RULES{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | @args = $redactor->(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 | return join(' ', $name, @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # OpenTelemetry Integration | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | tracer => $args{tracer}, # OTel tracer | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | meter => $args{meter}, # OTel meter | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | debug => $args{debug}, # Debug logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | include_args => $args{include_args} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | redact => $args{redact} // 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | host => $args{host} // 'localhost', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | port => $args{port} // 6379, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | database => $args{database} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%5/10
$args{"include_args"} // 0
$args{"redact"} // 1
$args{"host"} // "localhost"
$args{"port"} // 6379
$args{"database"} // 0
MC/DC0%0/1
$args{"include_args"} // 0
$args{"include_args"}
MC/DC0%0/1
$args{"redact"} // 1
$args{"redact"}
MC/DC0%0/1
$args{"host"} // "localhost"
$args{"host"}
MC/DC0%0/1
$args{"port"} // 6379
$args{"port"}
MC/DC0%0/1
$args{"database"} // 0
$args{"database"}
Truth table50%1/2
A
A= $args{"include_args"}
Truth table50%1/2
A
A= $args{"redact"}
Truth table50%1/2
A
A= $args{"host"}
Truth table50%1/2
A
A= $args{"port"}
Truth table50%1/2
A
A= $args{"database"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Metrics (lazy-initialized) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | _commands_counter => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | _commands_histogram => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | _connections_gauge => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | _errors_counter => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | _reconnects_counter => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | _pipeline_histogram => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Initialize metrics (call after meter is set) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | sub _init_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_metrics: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | return unless $self->{meter}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | return if $self->{_metrics_initialized}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $meter = $self->{meter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $self->{_commands_counter} = $meter->create_counter( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | name => 'redis.commands.total', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | description => 'Total Redis commands executed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | unit => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $self->{_commands_histogram} = $meter->create_histogram( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | name => 'redis.commands.duration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | description => 'Redis command latency', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | unit => 'ms', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->{_connections_gauge} = $meter->create_up_down_counter( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | name => 'redis.connections.active', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | description => 'Current active connections', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | unit => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->{_errors_counter} = $meter->create_counter( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | name => 'redis.errors.total', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | description => 'Total Redis errors by type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | unit => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->{_reconnects_counter} = $meter->create_counter( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | name => 'redis.reconnects.total', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | description => 'Total reconnection attempts', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | unit => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->{_pipeline_histogram} = $meter->create_histogram( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | name => 'redis.pipeline.size', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | description => 'Commands per pipeline', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | unit => '1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->{_metrics_initialized} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # Start a span for a command | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub start_command_span { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_command_span: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | my $command_name = uc($cmd[0] // 'UNKNOWN'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cmd[0] // "UNKNOWN"
MC/DC0%0/1
$cmd[0] // "UNKNOWN"
$cmd[0]
Truth table0%0/2
A
A= $cmd[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $span; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($self->{tracer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my $span_name = "redis.$command_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | my $statement = format_command_for_span( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $self->{include_args}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | $self->{redact}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | @cmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | $span = $self->{tracer}->create_span( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | name => $span_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | kind => 'client', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | attributes => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 'db.system' => 'redis', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 'db.operation' => $command_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 'db.statement' => $statement, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 'net.peer.name' => $self->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 'net.peer.port' => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 'db.redis.database_index' => $self->{database}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # Always return a context for metrics tracking | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | span => $span, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | start_time => time(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | command => $command_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # End a command span | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub end_command_span { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_command_span: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my ($self, $context, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | return unless $context; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $elapsed_ms = (time() - $context->{start_time}) * 1000; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # Record metrics (always, regardless of span) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->_record_command_metrics($context->{command}, $elapsed_ms, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # End span if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ($context->{span}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ($error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $context->{span}->set_status('error', "$error"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $context->{span}->record_exception($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $context->{span}->end; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # Record command metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub _record_command_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_record_command_metrics: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($self, $command, $elapsed_ms, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->_init_metrics; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my %labels = (command => $command); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($self->{_commands_counter}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->{_commands_counter}->add(1, \%labels); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ($self->{_commands_histogram}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $self->{_commands_histogram}->record($elapsed_ms, \%labels); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($error && $self->{_errors_counter}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$error and $self->{"_errors_counter"}
MC/DC0%0/2
$error and $self->{"_errors_counter"}
$error
$self->{"_errors_counter"}
Truth table0%0/3
A and B
A= $errorB= $self->{"_errors_counter"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my $error_type = ref($error) || 'unknown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $error || 'unknown'
MC/DC0%0/1
ref $error || 'unknown'
ref $error
Truth table0%0/2
A
A= ref $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $error_type =~ s/.*:://; # Strip package prefix | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->{_errors_counter}->add(1, { type => $error_type }); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Record pipeline metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub record_pipeline { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_pipeline: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my ($self, $size, $elapsed_ms) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $self->_init_metrics; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ($self->{_pipeline_histogram}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $self->{_pipeline_histogram}->record($size); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($self->{_commands_histogram}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $self->{_commands_histogram}->record($elapsed_ms, { command => 'PIPELINE' }); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # Record connection event | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | sub record_connection { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_connection: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my ($self, $delta) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $self->_init_metrics; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($self->{_connections_gauge}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->{_connections_gauge}->add($delta); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # Record reconnection attempt | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub record_reconnect { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
record_reconnect: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $self->_init_metrics; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | if ($self->{_reconnects_counter}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->{_reconnects_counter}->add(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Debug Logging | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub log_send { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_send: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my ($self, @cmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return unless $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $formatted = format_command_for_log(@cmd); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | if (ref $self->{debug} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $self->{debug}->('send', $formatted); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | warn "[REDIS SEND] $formatted\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub log_recv { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_recv: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my ($self, $result, $elapsed_ms) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return unless $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $summary = _summarize_result($result); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $msg = sprintf("[REDIS RECV] %s (%.2fms)", $summary, $elapsed_ms); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if (ref $self->{debug} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $self->{debug}->('recv', $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | warn "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub log_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_error: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my ($self, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | return unless $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $msg = "[REDIS ERROR] $error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if (ref $self->{debug} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $self->{debug}->('error', $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | warn "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub log_event { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log_event: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my ($self, $event, $details) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | return unless $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | my $msg = "[REDIS EVENT] $event" . ($details ? ": $details" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if (ref $self->{debug} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $self->{debug}->('event', $msg); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | warn "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Summarize result without exposing values | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub _summarize_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_summarize_result: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my ($result) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | return 'nil' unless defined $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if (ref $result eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return 'array[' . scalar(@$result) . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | elsif (ref $result eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return 'hash{' . scalar(keys %$result) . '}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | ▶ | elsif (ref $result && $result->can('message')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $result and $result->can("message")
MC/DC0%0/2
ref $result and $result->can("message")
ref $result
$result->can("message")
Truth table0%0/3
A and B
A= ref $resultB= $result->can("message")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return 'error: ' . $result->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | elsif (length($result) > 100) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return 'string[' . length($result) . ' bytes]'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # Short strings are OK to show type | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | return 'OK' if $result eq 'OK'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | return 'PONG' if $result eq 'PONG'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | return 'QUEUED' if $result eq 'QUEUED'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | return 'integer' if $result =~ /^-?\d+$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return 'string[' . length($result) . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 92 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||