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::SignalFx; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
2117
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
9
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
10
|
2
|
|
|
2
|
|
10
|
use base qw( Metrics::Any::Adapter::Statsd ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
895
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# See also |
15
|
|
|
|
|
|
|
# https://docs.signalfx.com/en/latest/integrations/agent/monitors/collectd-statsd.html |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
C - a metrics reporting adapter for SignalFx |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Metrics::Any::Adapter 'SignalFx'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This extension of L supports the additional tag |
26
|
|
|
|
|
|
|
reporting syntax defined by F to report labelled metrics. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _labels |
31
|
|
|
|
|
|
|
{ |
32
|
5
|
|
|
5
|
|
9
|
my ( $labelnames, $labelvalues ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
7
|
my @labels; |
35
|
5
|
|
|
|
|
14
|
foreach ( 0 .. $#$labelnames ) { |
36
|
5
|
|
|
|
|
15
|
push @labels, "$labelnames->[$_]=$labelvalues->[$_]"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
19
|
return "[" . join( ",", @labels ) . "]"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub send |
43
|
|
|
|
|
|
|
{ |
44
|
4
|
|
|
4
|
0
|
8
|
my $self = shift; |
45
|
4
|
|
|
|
|
8
|
my ( $stats, $labelnames, $labelvalues ) = @_; |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
6
|
my %labelledstats; |
48
|
4
|
50
|
|
|
|
10
|
if( $labelnames ) { |
49
|
4
|
|
|
|
|
14
|
foreach my $name ( keys %$stats ) { |
50
|
5
|
|
|
|
|
10
|
my $value = $stats->{$name}; |
51
|
5
|
|
|
|
|
15
|
my @parts = split m/\./, $name; |
52
|
5
|
|
|
|
|
13
|
$parts[-1] = _labels( $labelnames, $labelvalues ) . $parts[-1]; |
53
|
5
|
|
|
|
|
13
|
$name = join ".", @parts; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
17
|
$labelledstats{$name} = $value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
%labelledstats = %$stats; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
14
|
$self->SUPER::send( \%labelledstats ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Paul Evans |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0x55AA; |