mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
wip: tests for prometheus
This commit is contained in:
parent
53280ed562
commit
da7a27552a
3 changed files with 49 additions and 0 deletions
4
tests/prometheus/dune
Normal file
4
tests/prometheus/dune
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
(test
|
||||
(name t_prom)
|
||||
(libraries tiny_httpd.prometheus))
|
||||
22
tests/prometheus/t_prom.expected
Normal file
22
tests/prometheus/t_prom.expected
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
==== first try ====
|
||||
```
|
||||
# TYPE yolo_gauge gauge
|
||||
yolo_gauge{level="max"} 2525
|
||||
# HELP t_c2 more awesome than c1
|
||||
# TYPE t_c2 counter
|
||||
t_c2 1
|
||||
# TYPE t_c1 counter
|
||||
t_c1 42
|
||||
|
||||
```
|
||||
==== second try====
|
||||
```
|
||||
# TYPE yolo_gauge gauge
|
||||
yolo_gauge{level="max"} 42000
|
||||
# HELP t_c2 more awesome than c1
|
||||
# TYPE t_c2 counter
|
||||
t_c2 2
|
||||
# TYPE t_c1 counter
|
||||
t_c1 53
|
||||
|
||||
```
|
||||
23
tests/prometheus/t_prom.ml
Normal file
23
tests/prometheus/t_prom.ml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
module P = Tiny_httpd_prometheus
|
||||
|
||||
let pf = Printf.printf
|
||||
let reg = P.Registry.create ()
|
||||
let c1 = P.Counter.create reg "t_c1"
|
||||
let c2 = P.Counter.create reg "t_c2" ~descr:"more awesome than c1"
|
||||
let g1 = P.Gauge.create reg ~tags:[ "level", "max" ] "yolo_gauge"
|
||||
|
||||
let () =
|
||||
print_endline "==== first try ====";
|
||||
P.Counter.inc_by c1 42;
|
||||
P.Counter.inc c2;
|
||||
P.Gauge.set g1 2525;
|
||||
|
||||
pf "```\n%s\n```\n" @@ P.Registry.emit_str reg
|
||||
|
||||
let () =
|
||||
print_endline "==== second try====";
|
||||
P.Counter.inc_by c1 11;
|
||||
P.Counter.inc c2;
|
||||
P.Gauge.set g1 42_000;
|
||||
|
||||
pf "```\n%s\n```\n" @@ P.Registry.emit_str reg
|
||||
Loading…
Add table
Reference in a new issue