Authentication/Handler/Size.pm

filter: Statementstmt 34.0% 16 / 47 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.4% 5 / 13 Podpod 12.5% 1 / 8 totaltotal 30.5% 22 / 72 CC 5 SCAR 23.0
CC
5
Cov
31%
close_callback
30.0
default_config
2.0
grafana_rows
2.0
CRAP 9.9
« Authentication/App/Blocker/App/Command/delete.pm ↑ Summary Authentication/Tester/HandlerTester.pm »
1 package Mail::Milter::Authentication::Handler::Size;
2 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Mail::Milter::Authentication::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: Handler class for message size metrics
7 1 our $VERSION = '4.20261111'; # VERSION
8 1 ▶use base 'Mail::Milter::Authentication::Handler';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub default_config {
Subroutine default_config: not called CC=1 SCAR=6.9
Pod undocumented
11 0 return {};
12 }
13  
14 0 ▶sub grafana_rows {
Subroutine grafana_rows: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my ( $self ) = @_;
16 0 my @rows;
17 0 push @rows, $self->get_json( 'Size_metrics' );
18 0 return \@rows;
19 }
20  
21 0 ▶sub register_metrics {
Subroutine register_metrics: not called CC=1 SCAR=6.9
Pod documented
22 return {
23 0 'size_total' => 'The number of emails processed for Size',
24 'size_header_bytes_added_total' => 'The header size added to emails processed for Size',
25 'size_header_bytes_total' => 'The header size of emails processed for Size',
26 'size_body_bytes_total' => 'The body size of emails processed for Size',
27 };
28 }
29  
30 0 ▶sub envfrom_callback {
Subroutine envfrom_callback: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my ( $self, $env_from ) = @_;
32 0 $self->{'headersize'} = 0;
33 0 $self->{'bodysize'} = 0;
34 }
35  
36 0 ▶sub header_callback {
Subroutine header_callback: not called CC=1 SCAR=6.9
Pod undocumented
37 0 my ( $self, $header, $value ) = @_;
38 0 $self->{ 'headersize' } = $self->{ 'headersize' } + length( $header . ': ' . $value ) + 2;
39 }
40  
41 0 ▶sub body_callback {
Subroutine body_callback: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my ( $self, $body_chunk ) = @_;
43 0 $self->{ 'bodysize' } = $self->{ 'bodysize' } + length ( $body_chunk );
44 }
45  
46 0 ▶sub eom_callback {
Subroutine eom_callback: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my ($self) = @_;
48 0 $self->metric_count( 'size_total', {}, 1 );
49 0 $self->metric_count( 'size_header_bytes_total', {}, $self->{ 'headersize' } );
50 0 $self->metric_count( 'size_body_bytes_total', {}, $self->{ 'bodysize' } );
51 }
52  
53 0 ▶sub close_callback {
Subroutine close_callback: not called CC=5 SCAR=34.0
Pod undocumented
54 0 my ( $self ) = @_;
55  
56 0 my $top_handler = $self->get_top_handler();
57 0 ▶ if ( exists( $top_handler->{'pre_headers'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $top_handler->{"pre_headers"}) 0 0 0
58 0 foreach my $header ( @{ $top_handler->{'pre_headers'} } ) {
59 0 my $size = length( $header->{'field'} ) + length ( $header->{'value'} ) + 3;
60 0 $self->metric_count( 'size_header_bytes_added_total', { where => 'pre', 'header' => $header->{'field'} }, $size );
61 }
62 }
63 0 ▶ if ( exists( $top_handler->{'add_headers'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $top_handler->{"add_headers"}) 0 0 0
64 0 foreach my $header ( @{ $top_handler->{'add_headers'} } ) {
65 0 my $size = length( $header->{'field'} ) + length ( $header->{'value'} ) + 3;
66 0 $self->metric_count( 'size_header_bytes_added_total', { where => 'add', 'header' => $header->{'field'} }, $size );
67 }
68 }
69  
70 0 delete $self->{'bodysize'};
71 0 delete $self->{'headersize'};
72 }
73  
74 1 1;
75  
76 __END__
« Authentication/App/Blocker/App/Command/delete.pm ↑ Summary Authentication/Tester/HandlerTester.pm »