1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#!perl
use Test::More;
use Prometheus::Tiny::Shared;
use File::Temp qw(tmpnam);
my $filename = scalar tmpnam();
my $p = Prometheus::Tiny::Shared->new(filename => $filename);
# parent, mark it and start a count
$p->set('parent', 1);
$p->set('count', 1);
my $pid = fork;
if (!$pid) {
# child, mark it too and bump the count
$p->set('child', 1);
$p->inc('count');
exit 0;
}
# parent, bump the count here too
$p->inc('count');
wait();
is $p->format, <<EOF, 'correct metrics after fork';
child 1
count 3
parent 1
EOF
done_testing;
|