.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Prometheus::PerlCollector 3pm" .TH Net::Prometheus::PerlCollector 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "Net::Prometheus::PerlCollector" \- obtain statistics about the perl interpreter .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 2 \& use Net::Prometheus; \& use Net::Prometheus::PerlCollector; \& \& my $client = Net::Prometheus\->new; \& $client\->register( Net::Prometheus::PerlCollector\->new ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides a class that collects metrics about the perl interpreter itself. .SS Metrics .IX Subsection "Metrics" The following metrics are collected: .IP \(bu 2 \&\f(CW\*(C`perl_info\*(C'\fR .Sp An info gauge (i.e. whose value is always 1) with a \f(CW\*(C`version\*(C'\fR label giving the perl interpreter version .Sp .Vb 3 \& # HELP perl_info Information about the Perl interpreter \& # TYPE perl_info gauge \& perl_info{version="5.30.0"} 1 .Ve .PP If the optional XS module was compiled at build time, the following extra are also reported: .IP \(bu 2 \&\f(CW\*(C`perl_heap_arenas\*(C'\fR .Sp A gauge giving the number of arenas the heap is split into. .IP \(bu 2 \&\f(CW\*(C`perl_heap_svs\*(C'\fR .Sp A gauge giving the total number of SVs allocated on the heap. .PP .Vb 6 \& # HELP perl_heap_arenas Number of arenas in the Perl heap \& # TYPE perl_heap_arenas gauge \& perl_heap_arenas 159 \& # HELP perl_heap_svs Number of SVs in the Perl heap \& # TYPE perl_heap_svs gauge \& perl_heap_svs 26732 .Ve .PP Note that the way these metrics are collected requires counting them all every time. While this code is relatively efficient, it is still a linear scan, and may itself cause some slowdown of the process at the time it is collected, if the heap has grown very large, containing a great number of SVs. .PP Extra detail can be obtained about the types of heap objects by setting .PP .Vb 1 \& $Net::Prometheus::PerlCollector::DETAIL = 1; .Ve .PP This will be slightly more expensive to count, but will yield in addition a detailed breakdown by object type. .PP .Vb 11 \& # HELP perl_heap_svs_by_type Number of SVs classified by type \& # TYPE perl_heap_svs_by_type gauge \& perl_heap_svs_by_type{type="ARRAY"} 2919 \& perl_heap_svs_by_type{type="CODE"} 1735 \& perl_heap_svs_by_type{type="GLOB"} 2647 \& perl_heap_svs_by_type{type="HASH"} 470 \& perl_heap_svs_by_type{type="INVLIST"} 68 \& perl_heap_svs_by_type{type="IO"} 12 \& perl_heap_svs_by_type{type="NULL"} 8752 \& perl_heap_svs_by_type{type="REGEXP"} 171 \& perl_heap_svs_by_type{type="SCALAR"} 9958 .Ve .PP This level of detail is unlikely to be useful for most generic production purposes but may be helpful to set in specific processes when investigating specific memory-related issues for a limited time. .PP For an even greater level of detail, set the value to 2 to additionally obtain another breakdown of blessed objects by class: .PP .Vb 6 \& # HELP perl_heap_svs_by_class Number of SVs classified by class \& # TYPE perl_heap_svs_by_class gauge \& ... \& perl_heap_svs_by_class{class="Net::Prometheus"} 1 \& perl_heap_svs_by_class{class="Net::Prometheus::PerlCollector"} 1 \& perl_heap_svs_by_class{class="Net::Prometheus::ProcessCollector::linux"} 1 .Ve .PP Note that this will yield a large amount of output for any non-trivially sized program, so should only be enabled under carefully-controlled conditions. .PP The value of this variable can be overridden on a per-collection basis by passing the option .PP .Vb 1 \& Net::Prometheus\->render( { perl_collector_detail => 1 } ); # or 2 .Ve .PP This may be more convenient for short-term traces from exporters that parse HTTP query parameters into collector options. .PP .Vb 1 \& GET .../metrics?perl_collector_detail=1 .Ve .SH AUTHOR .IX Header "AUTHOR" Paul Evans