File: net-async-http-server.pl

package info (click to toggle)
libnet-prometheus-perl 0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: perl: 1,847; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 490 bytes parent folder | download
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
#!/usr/bin/perl

use v5.14;
use warnings;

use Net::Prometheus;

use IO::Async::Loop;
use Net::Async::HTTP::Server::PSGI;

use Metrics::Any::Adapter 'Prometheus';

use constant LISTEN_PORT => 8200;

my $client = Net::Prometheus->new;

$client->new_gauge(
   name => "ten",
   help => "The number ten",
)->set( 10 );

printf STDERR "Serving metrics on http://[::]:%d\n", LISTEN_PORT;

my $loop = IO::Async::Loop->new;

$client->export_to_IO_Async( $loop, port => LISTEN_PORT );

$loop->run;