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. $delta defaults to 1 when 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