File Coverage

blib/lib/Mojolicious/Plugin/Prometheus/Shared/FastMmap.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::Prometheus::Shared::FastMmap;
2 2     2   1489 use Mojo::Base 'Mojolicious::Plugin::Prometheus';
  2         111022  
  2         11  
3 2     2   24039 use Role::Tiny::With;
  2         451  
  2         146  
4              
5             our $VERSION = '1.0.0';
6              
7             with 'Mojolicious::Plugin::Prometheus::Role::SharedFastMmap';
8             1;
9             __END__
10            
11             =for stopwords mmapped
12            
13             =encoding utf8
14            
15             =head1 NAME
16            
17             Mojolicious::Plugin::Prometheus::Shared::FastMmap - Mojolicious Plugin
18            
19             =head1 SYNOPSIS
20            
21             # Mojolicious
22             $self->plugin('Prometheus::Shared::FastMmap');
23            
24             # Mojolicious::Lite
25             plugin 'Prometheus::Shared::FastMmap';
26            
27             # Mojolicious::Lite, with custom response buckets (seconds)
28             plugin 'Prometheus::Shared::FastMmap' => { response_buckets => [qw/4 5 6/] };
29            
30             =head1 DESCRIPTION
31            
32             L<Mojolicious::Plugin::Prometheus::Shared::FastMmap> is a L<Mojolicious> plugin that exports Prometheus metrics from Mojolicious, using a shared mmapped file between workers.
33            
34             It uses L<Mojolicious::Plugin::Prometheus> under the hood, and adds a shared cache using L<Mojolicious::Plugin::CHI> + L<CHI> + L<Cache::FastMmap> to provide metrics for all workers under a pre-forking daemon like L<Mojo::Server::Hypnotoad>.
35            
36             See L<Mojolicious::Plugin::Prometheus> for more complete documentation.
37            
38             =head1 METHODS
39            
40             L<Mojolicious::Plugin::Prometheus::Shared::FastMmap> inherits all methods from
41             L<Mojolicious::Plugin::Prometheus> and implements no new ones.
42            
43             =head2 register
44            
45             $plugin->register($app, \%config);
46            
47             Register plugin in L<Mojolicious> application.
48            
49             C<%config> can have all the original values as L<Mojolicious::Plugin::Prometheus>, and adds the following keys:
50            
51             =over 2
52            
53             =item * cache_dir
54            
55             The path to store the mmapped file. See L<CHI::Driver::FastMmap> for details (used as root_dir).
56            
57             Default: ./cache
58            
59             =item * cache_size
60            
61             Defaults to '5m'. See L<CHI::Driver::FastMmap> for details.
62            
63             =back
64            
65             =head1 AUTHOR
66            
67             Vidar Tyldum
68            
69             =head1 COPYRIGHT AND LICENSE
70            
71             Copyright (C) 2018, Vidar Tyldum
72            
73             This program is free software, you can redistribute it and/or modify it under
74             the terms of the Artistic License version 2.0.
75            
76             =head1 SEE ALSO
77            
78             =over 2
79            
80             =item L<Mojolicious::Plugin::Prometheus>
81            
82             =item L<CHI::Driver::FastMmap>
83            
84             =item L<Net::Prometheus>
85            
86             =item L<Mojolicious>
87            
88             =item L<Mojolicious::Guides>
89            
90             =item L<http://mojolicious.org>
91            
92             =back
93            
94             =cut
95