line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DataDog::DogStatsd::Helper; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
168324
|
use strict; |
|
2
|
|
|
|
|
31
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
104
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
16
|
use base qw( Exporter ); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
466
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/stats_inc stats_dec stats_timing stats_gauge stats_count stats_histogram/; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
993
|
use DataDog::DogStatsd; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
952
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
## no critic (Subroutines::RequireFinalReturn) |
13
|
|
|
|
|
|
|
sub stats_inc { |
14
|
6
|
|
|
6
|
0
|
3571
|
my @args = @_; |
15
|
|
|
|
|
|
|
# support stats_inc('test.blabla', 0.1); as well |
16
|
6
|
100
|
100
|
|
|
45
|
if (@args > 1 and $args[1] =~ /^[\d\.]+$/) { |
17
|
|
|
|
|
|
|
# actually ppl wants stats_count |
18
|
1
|
50
|
|
|
|
5
|
warn "stats_inc sample_rate makes no sense for more than 1\n" if $args[1] > 1; |
19
|
1
|
|
|
|
|
4
|
$args[1] = {sample_rate => $args[1]}; |
20
|
|
|
|
|
|
|
} |
21
|
6
|
|
|
|
|
36
|
__get_dogstatsd()->increment(@args); |
22
|
|
|
|
|
|
|
} |
23
|
4
|
|
|
4
|
0
|
3727
|
sub stats_dec { __get_dogstatsd()->decrement(@_); } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub stats_timing { |
26
|
5
|
|
|
5
|
0
|
5332
|
my @args = @_; |
27
|
|
|
|
|
|
|
# support stats_timing('connection_time', 1000 * $interval, 0.1); as well |
28
|
5
|
100
|
100
|
|
|
39
|
if (@args > 2 and $args[2] =~ /^[\d\.]+$/) { |
29
|
|
|
|
|
|
|
# actually ppl wants stats_count |
30
|
1
|
50
|
|
|
|
5
|
warn "stats_timing sample_rate makes no sense for more than 1\n" if $args[2] > 1; |
31
|
1
|
|
|
|
|
3
|
$args[2] = {sample_rate => $args[2]}; |
32
|
|
|
|
|
|
|
} |
33
|
5
|
|
|
|
|
15
|
__get_dogstatsd()->timing(@args); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
4
|
0
|
4092
|
sub stats_gauge { __get_dogstatsd()->gauge(@_); } |
37
|
0
|
|
|
0
|
0
|
0
|
sub stats_count { __get_dogstatsd()->count(@_); } |
38
|
1
|
|
|
1
|
0
|
873
|
sub stats_histogram { __get_dogstatsd()->histogram(@_); } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $__DOGSTATSD; |
41
|
|
|
|
|
|
|
sub __get_dogstatsd { |
42
|
5
|
|
66
|
5
|
|
21
|
$__DOGSTATSD ||= DataDog::DogStatsd->new; |
43
|
5
|
|
|
|
|
16
|
return $__DOGSTATSD; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
__END__ |