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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!/usr/bin/perl
use v5.14;
use warnings;
use Test2::V0;
use Metrics::Any '$metrics',
name_prefix => [qw( testing )];
use Metrics::Any::Adapter 'Test';
# Force the adapter to exist
$metrics->adapter;
# Prefix is applied
{
Metrics::Any::Adapter::Test->clear;
$metrics->make_counter( c => name => [qw( counter )] );
$metrics->inc_counter( c => );
$metrics->make_distribution( d => name => [qw( distribution )] );
$metrics->report_distribution( d => 100 );
$metrics->make_gauge( g => name => [qw( gauge )] );
$metrics->inc_gauge( g => );
$metrics->make_timer( t => name => [qw( timer )] );
$metrics->report_timer( t => 2 );
is( Metrics::Any::Adapter::Test->metrics, <<'EOF',
testing_counter = 1
testing_distribution_count = 1
testing_distribution_total = 100
testing_gauge = 1
testing_timer_count = 1
testing_timer_total = 2
EOF
'Metrics have name prefices' );
}
# Default names
{
Metrics::Any::Adapter::Test->clear;
$metrics->make_counter( 'c2' );
$metrics->inc_counter( c2 => );
$metrics->make_distribution( 'd2' );
$metrics->report_distribution( d2 => 100 );
$metrics->make_gauge( 'g2' );
$metrics->inc_gauge( g2 => );
$metrics->make_timer( 't2' );
$metrics->report_timer( t2 => 2 );
is( Metrics::Any::Adapter::Test->metrics, <<'EOF',
testing_c2 = 1
testing_d2_count = 1
testing_d2_total = 100
testing_g2 = 1
testing_t2_count = 1
testing_t2_total = 2
EOF
'Metrics have name prefices' );
}
done_testing;
|