| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Prometheus::Role::SharedFastMmap; |
|
2
|
2
|
|
|
2
|
|
813
|
use Role::Tiny; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
after register => sub { |
|
5
|
|
|
|
|
|
|
my ($self, $app, $config) = @_; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$app->plugin( |
|
8
|
|
|
|
|
|
|
'CHI' => { |
|
9
|
|
|
|
|
|
|
Prometheus_plugin => { |
|
10
|
|
|
|
|
|
|
driver => 'FastMmap', |
|
11
|
|
|
|
|
|
|
root_dir => $config->{cache_dir} // 'cache', |
|
12
|
|
|
|
|
|
|
cache_size => $config->{cache_size} // '5m', |
|
13
|
|
|
|
|
|
|
empty_on_exit => 1, |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$app->hook( |
|
19
|
|
|
|
|
|
|
after_render => sub { |
|
20
|
|
|
|
|
|
|
my ($c) = @_; |
|
21
|
|
|
|
|
|
|
$app->chi('Prometheus_plugin')->set($$ => $app->prometheus->render); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->route->to( |
|
26
|
|
|
|
|
|
|
cb => sub { |
|
27
|
|
|
|
|
|
|
my ($c) = @_; |
|
28
|
|
|
|
|
|
|
$c->render( text => join ("\n", map { ($app->chi('Prometheus_plugin')->get($_)) } $app->chi('Prometheus_plugin')->get_keys()), format => 'txt' ); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
}; |
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
|