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.09;
7              
8 4     4   933 use v5.14;
  4         14  
9 4     4   22 use warnings;
  4         8  
  4         326  
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 13 my $class = shift;
32 5         31 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   27 no strict 'refs';
  4         6  
  4         284  
43       23     *$method = sub {};
44             }
45              
46             # Batch mode is supported but does nothing
47 4     4   26 use constant HAVE_BATCH_MODE => 1;
  4         8  
  4         430  
48       1 0   sub add_batch_mode_callback {}
49              
50             =head1 AUTHOR
51              
52             Paul Evans
53              
54             =cut
55              
56             0x55AA;