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