| 1 | # You may distribute under the terms of either the GNU General Public License | ||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||
| 3 | # | ||
| 4 | # (C) Paul Evans, 2022 -- leonerd@leonerd.org.uk | ||
| 5 | |||
| 6 | package Future::AsyncAwait::Metrics 0.01; | ||
| 7 | |||
| 8 | 2 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 2 | ▶ | use Metrics::Any 0.09 '$metrics', |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | name_prefix => [ 'asyncawait' ], | ||
| 13 | 2 | strict => 1; | |
| 14 | |||
| 15 | 2 | require XSLoader; | |
| 16 | 2 | XSLoader::load( __PACKAGE__, our $VERSION ); | |
| 17 | |||
| 18 | =head1 NAME | ||
| 19 | |||
| 20 | C<Future::AsyncAwait::Metrics> - report metrics from C<Future::AsyncAwait> to C<Metrics::Any> | ||
| 21 | |||
| 22 | =head1 SYNOPSIS | ||
| 23 | |||
| 24 | use Future::AsyncAwait::Metrics; | ||
| 25 | |||
| 26 | # Additional metrics will now be reported | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | This module provides no functions or other import symbols. Instead, by simply | ||
| 31 | loading it somewhere in the program, additional metrics are created and | ||
| 32 | reported to L<Metrics::Any> about the operation of L<Future::AsyncAwait>. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | =head1 METRICS | ||
| 37 | |||
| 38 | The following metrics are reported: | ||
| 39 | |||
| 40 | =head2 asyncawait_suspends | ||
| 41 | |||
| 42 | A counter of the number of times an C<async sub> has been suspended. | ||
| 43 | |||
| 44 | =head2 asyncawait_resumes | ||
| 45 | |||
| 46 | A counter of the number of times an C<async sub> has been resumed. | ||
| 47 | |||
| 48 | =head2 asyncawait_current_subs | ||
| 49 | |||
| 50 | A gauge giving the current count of C<async sub> instances currently | ||
| 51 | suspended. | ||
| 52 | |||
| 53 | =head2 asyncawait_states_created | ||
| 54 | |||
| 55 | A counter of the number of times that C<async sub> context storage has been | ||
| 56 | created. This may be less than C<asyncawait_suspends> because storage is | ||
| 57 | reused for multiple C<await> calls within any one function invocation. | ||
| 58 | |||
| 59 | =head2 asyncawait_states_destroyed | ||
| 60 | |||
| 61 | A counter giving the number of times that C<async sub> context storage has | ||
| 62 | been destroyed. | ||
| 63 | |||
| 64 | =head2 asyncawait_current_states | ||
| 65 | |||
| 66 | A gauge giving the current count of C<async sub> context storage instances. | ||
| 67 | This may be less than C<asyncawait_current_subs> because not all of them may | ||
| 68 | be currently suspended. | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | 2 | $metrics->make_counter( suspends => | |
| 73 | description => "Count of the number of times an async sub has been suspended", | ||
| 74 | ); | ||
| 75 | |||
| 76 | 2 | $metrics->make_counter( resumes => | |
| 77 | description => "Count of the number of times an async sub has been resumed", | ||
| 78 | ); | ||
| 79 | |||
| 80 | 2 | $metrics->make_gauge( current_subs => | |
| 81 | description => "Current number of suspended async subs", | ||
| 82 | ); | ||
| 83 | |||
| 84 | 2 | $metrics->make_counter( states_created => | |
| 85 | description => "Count of the number of times async sub state storage has been created", | ||
| 86 | ); | ||
| 87 | 2 | $metrics->make_counter( states_destroyed => | |
| 88 | description => "Count of the number of times async sub state storage has been destroyed", | ||
| 89 | ); | ||
| 90 | 2 | $metrics->make_gauge( current_states => | |
| 91 | description => "Current number of async sub state storage instances", | ||
| 92 | ); | ||
| 93 | |||
| 94 | =head1 AUTHOR | ||
| 95 | |||
| 96 | Paul Evans <leonerd@leonerd.org.uk> | ||
| 97 | |||
| 98 | =cut | ||
| 99 | |||
| 100 | 2 | 0x55AA; | |