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
|
|
1941
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
9
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
10
|
2
|
|
|
2
|
|
9
|
use base qw( Metrics::Any::Adapter::Statsd ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
795
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
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
|
|
|
|
|
6
|
my @labels; |
35
|
5
|
|
|
|
|
11
|
foreach ( 0 .. $#$labelnames ) { |
36
|
5
|
|
|
|
|
14
|
push @labels, "$labelnames->[$_]=$labelvalues->[$_]"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
17
|
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
|
|
|
|
|
5
|
my %labelledstats; |
48
|
4
|
50
|
|
|
|
8
|
if( $labelnames ) { |
49
|
4
|
|
|
|
|
11
|
foreach my $name ( keys %$stats ) { |
50
|
5
|
|
|
|
|
8
|
my $value = $stats->{$name}; |
51
|
5
|
|
|
|
|
14
|
my @parts = split m/\./, $name; |
52
|
5
|
|
|
|
|
11
|
$parts[-1] = _labels( $labelnames, $labelvalues ) . $parts[-1]; |
53
|
5
|
|
|
|
|
11
|
$name = join ".", @parts; |
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
14
|
$labelledstats{$name} = $value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
0
|
%labelledstats = %$stats; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
12
|
$self->SUPER::send( \%labelledstats ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Paul Evans |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
0x55AA; |