Net::P...ounter(3pm)
π NAME π
Net::Prometheus::Counter β it's giving a monotonically-increasing counter metric β¨
πΈ SYNOPSIS πΈ
okay so here's the whole vibe in code, bestie:
use Net::Prometheus;
my $client = Net::Prometheus->new;
my $counter = $client->new_counter(
name => "requests",
help => "Number of received requests",
);
sub handle_request
{
$counter->inc;
...
}
likeβ¦ you make it, you bump it, you move on with your life. periodt. π
π¦ DESCRIPTION π¦
so this class is literally a counter metric β a value that just goes π monotonically increases and never ever goes back down. main character energy, honestly. it's usually there to represent occurrences of some event that happens inside the instrumented program. count it. slay it. move on.
fun fact: it's a subclass of Net::Prometheus::Metric, so it inherited all that Metric goodness, iykyk π«Ά
π CONSTRUCTOR π
ngl, you don't normally build these yourself. like, you can, but the β¨canon eventβ¨ is to get one from the Net::Prometheus object that's gonna serve it:
$counter = $prometheus->new_counter( %args );
and it takes the exact same constructor arguments as documented over in Net::Prometheus::Metric. no secret menu, no extra lore. π
β¨ METHODS β¨
π« inc
three ways to call it, pick your fighter:
$counter->inc( @label_values, $delta );
$counter->inc( \%labels, $delta );
$child->inc( $delta );
what it does: increments the current value for the gauge π (yes bestie, the doc really says "gauge" there β we keep it 100, we don't edit the lore, we just report it fr fr).
$delta is what you're adding. if you don't pass it, it defaults to 1 β cute, convenient, iconic. and it must be non-negative, so no sneaky negative deltas, no reverse-aging this counter, the vibe check is strict and it's for your own good π₯
β οΈ reminder: non-negative only.$deltadefaults to1when omitted. that's the whole rule. don't fight it. π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the absolute legend behind this. bow down, say thank you. π«Ά
that's the whole page, bestie! this lil writeup shipped as part of the User Contributed Perl Documentation for perl v5.42.3, dated 2026-08-20, filed under Net::P...ounter(3pm) πΈ star it, bookmark it, tell your friends. mwah π
π¦ where this page comes from
- ubuntu stonking: libnet-prometheus-perl 0.16-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms