| 1 | package Mojolicious::Plugin::Prometheus::Collector::Perl; | ||||||||||
| 2 | 12 | ▶ | use Mojo::Base -base, -signatures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 12 | ▶ | use Mojo::Collection; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 12 | ▶ | use Net::Prometheus::Types qw( MetricSamples Sample ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 12 | ▶ | use Net::Prometheus::PerlCollector; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 12 | has detail => 0; | |||||||||
| 8 | 0 | ▶ | has labels_cb => sub {{}}; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 9 | 10 | ▶ | has perl_version => sub { ( $^V =~ m/^v(.*)$/ )[0] }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 13 | ▶ | sub collect($self, $opts) { | ||||||||
|
Subroutine
collect: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||
| 12 | 13 | my @samples = ( | |||||||||
| 13 | MetricSamples( | ||||||||||
| 14 | 'perl_info', | ||||||||||
| 15 | gauge => 'Perl interpreter version', | ||||||||||
| 16 | [ Sample( 'perl_info', [ version => $self->perl_version, $self->labels_cb->()->%* ], 1 ) ] | ||||||||||
| 17 | ), | ||||||||||
| 18 | ); | ||||||||||
| 19 | 13 | return @samples unless Net::Prometheus::PerlCollector::HAVE_XS; | |||||||||
| 20 | |||||||||||
| 21 | 13 | my ($arenas, $svs, $svs_by_type, $svs_by_class) = Net::Prometheus::PerlCollector::count_heap($self->detail); | |||||||||
| 22 | |||||||||||
| 23 | 13 | push @samples, MetricSamples( | |||||||||
| 24 | 'perl_heap_arenas', | ||||||||||
| 25 | gauge => 'Number of arenas in the Perl heap', | ||||||||||
| 26 | [ Sample('perl_heap_arenas', [$self->labels_cb->()->%*], $arenas) ] | ||||||||||
| 27 | ); | ||||||||||
| 28 | 13 | push @samples, MetricSamples( | |||||||||
| 29 | 'perl_heap_svs', | ||||||||||
| 30 | gauge => 'Number of SVs in the Perl heap', | ||||||||||
| 31 | [ Sample('perl_heap_svs', [$self->labels_cb->()->%*], $svs) ] | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 13 | ▶ | if($svs_by_type) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | my $by_type = Mojo::Collection->new(keys %$svs_by_type) | ||||||||||
| 36 | ->sort | ||||||||||
| 37 | 0 | ▶ | ->map(sub { Sample('perl_heap_svs_by_type', [ type => $_, $self->labels_cb->()->%* ], $svs_by_type->{$_}) }) | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 38 | 0 | ->to_array; | |||||||||
| 39 | 0 | push @samples, MetricSamples('perl_heap_svs_by_type', gauge => 'Number of SVs classified by type', $by_type); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 13 | ▶ | if($svs_by_class) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | my $by_class = Mojo::Collection->new(keys %$svs_by_class) | ||||||||||
| 44 | ->sort | ||||||||||
| 45 | 0 | ▶ | ->map(sub { Sample('perl_heap_svs_by_class', [ class => $_, $self->labels_cb->()->%* ], $svs_by_class->{$_}) }) | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 46 | 0 | ->to_array; | |||||||||
| 47 | 0 | push @samples, MetricSamples('perl_heap_svs_by_class', gauge => 'Number of SVs classified by class', $by_class); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 13 | return @samples; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 12 | 1; | |||||||||