File Coverage

blib/lib/Metrics/Any/Adapter/Null.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2020 -- leonerd@leonerd.org.uk
5              
6             package Metrics::Any::Adapter::Null 0.10;
7              
8 4     4   508 use v5.14;
  4         14  
9 4     4   22 use warnings;
  4         12  
  4         307  
10              
11             =head1 NAME
12              
13             C - a metrics reporting adapter which does nothing
14              
15             =head1 DESCRIPTION
16              
17             This L adapter type contains an empty stub implementation of the
18             adapter API, allowing a module to invoke methods on its metrics collector that
19             do not do anything.
20              
21             A program would run with this adapter by default unless it has requested a
22             different one, via the C statement.
23              
24             This adapter type claims to support batch mode, though the reporting callback
25             will never be invoked.
26              
27             =cut
28              
29             sub new
30             {
31 5     5 0 11 my $class = shift;
32 5         32 return bless {}, $class;
33             }
34              
35             # All of these are empty methods
36             foreach my $method (qw(
37             make_counter inc_counter_by
38             make_distribution report_distribution
39             make_gauge inc_gauge_by set_gauge_to
40             make_timer report_timer
41             )) {
42 4     4   30 no strict 'refs';
  4         8  
  4         301  
43       23     *$method = sub {};
44             }
45              
46             # Batch mode is supported but does nothing
47 4     4   30 use constant HAVE_BATCH_MODE => 1;
  4         23  
  4         412  
48       1 0   sub add_batch_mode_callback {}
49              
50             =head1 AUTHOR
51              
52             Paul Evans
53              
54             =cut
55              
56             0x55AA;