Metric...r::File(3pm)
π NAME π
Metrics::Any::Adapter::File β bestie, this one writes your metrics to a file. That's the whole vibe. πβ¨
π¦ SYNOPSIS π¦
use Metrics::Any::Adapter 'File', path => "metrics.log";
okay that's it, one line, she's low maintenance π
πΈ DESCRIPTION πΈ
So Metrics::Any has this adapter type, right, and what it does is take all the observations of your metric values and justβ¦ writes them into a file. That's it. That's the job. And honestly? Iconic. π
Why would you want that, you ask? Because sometimes you're debugging, or you're testing some code that reports metrics, and you just wanna see what it's saying. No cap, this is the move. π
Like, say you set the METRICS_ANY_ADAPTER environment variable to configure the adapter β boom, now a metric log gets written as a side-effect of running a unit test:
$ METRICS_ANY_ADAPTER=File:path=metrics.log perl -Mblib t/01test.t
and then you just open up that generated file and peek at what metric values got reported while the program was running. it's giving detective energy π΅οΈβοΈβ¨
Now here's a little trick that's so underrated: if you point it at /dev/null, then the full metrics generation path gets tested β your code under test still sees a "real" adapter, but the output goes absolutely nowhere. Like a little black hole. Nothing comes out. π³οΈπ
$ METRICS_ANY_ADAPTER=File:path=/dev/null ./Build test
Heads up though: distribution and timing metrics are tracked with a running total and a count of observations. Keep that in mind when you're reading the output, bestie. π
π¨ Important, fr fr: this adapter type does NOT support batch mode reporting. Just so you know. Don't come for me. π
π ARGUMENTS π
Here's the extra arguments she recognises (yes, plural grammar, no I did not write the original):
π path
The path to the file to write to. That's it. Give her a path, she writes to it. Simple queen behavior π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the icon, the legend, the main character who wrote this π«Ά
and that's the whole page, bestie!! this was documented as part of perl v5.36.0, dated 2023-09-29 β go forth and log your metrics, you absolute gem πβ¨πΈπ¦π
π¦ where this page comes from
- debian trixie: libmetrics-any-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmetrics-any-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmetrics-any-perl 0.10-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmetrics-any-perl 0.10-1 Β· 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