move conn_metrics to Vmm_core

This commit is contained in:
Hannes Mehnert 2019-10-12 02:15:44 +02:00
parent 13edb22db3
commit 866cd9041a
8 changed files with 25 additions and 23 deletions

View File

@ -3,23 +3,6 @@
open Astring
open Vmm_core
let conn_metrics kind =
let s = ref (0, 0) in
let open Metrics in
let doc = "connection statistics" in
let data () =
Data.v [
int "active" (fst !s) ;
int "total" (snd !s) ;
] in
let tags = Tags.string "kind" in
let src = Src.v ~doc ~tags:Tags.[ tags ] ~data "connections" in
(fun action ->
(match action with
| `Open -> s := (succ (fst !s), succ (snd !s))
| `Close -> s := (pred (fst !s), snd !s));
Metrics.add src (fun x -> x kind) (fun d -> d ()))
open Lwt.Infix
let process =

View File

@ -66,7 +66,7 @@ let open_fifo name =
let t = ref String.Map.empty
let fifos = Albatross_cli.conn_metrics "fifo"
let fifos = Vmm_core.conn_metrics "fifo"
let add_fifo id =
let name = Vmm_core.Name.to_string id in
@ -159,7 +159,7 @@ let handle s addr =
Vmm_lwt.safe_close s >|= fun () ->
Logs.warn (fun m -> m "disconnected")
let m = Albatross_cli.conn_metrics "unix"
let m = Vmm_core.conn_metrics "unix"
let jump _ influx =
Sys.(set_signal sigpipe Signal_ignore) ;

View File

@ -159,7 +159,7 @@ let handle mvar ring s addr =
end >>= fun () ->
Vmm_lwt.safe_close s
let m = Albatross_cli.conn_metrics "unix"
let m = Vmm_core.conn_metrics "unix"
let jump _ file influx =
Sys.(set_signal sigpipe Signal_ignore) ;

View File

@ -1,5 +1,22 @@
(* (c) 2017, 2018 Hannes Mehnert, all rights reserved *)
let conn_metrics kind =
let s = ref (0, 0) in
let open Metrics in
let doc = "connection statistics" in
let data () =
Data.v [
int "active" (fst !s) ;
int "total" (snd !s) ;
] in
let tags = Tags.string "kind" in
let src = Src.v ~doc ~tags:Tags.[ tags ] ~data "connections" in
(fun action ->
(match action with
| `Open -> s := (succ (fst !s), succ (snd !s))
| `Close -> s := (pred (fst !s), snd !s));
Metrics.add src (fun x -> x kind) (fun d -> d ()))
open Astring
let tmpdir = Fpath.(v "/var" / "run" / "albatross")

View File

@ -1,5 +1,7 @@
(* (c) 2018 Hannes Mehnert, all rights reserved *)
val conn_metrics : string -> [ `Close | `Open ] -> unit
type service = [ `Console | `Log | `Stats | `Vmmd ]
val socket_path : service -> string

View File

@ -64,7 +64,7 @@ let timer () =
Vmm_lwt.safe_close s)
outs
let m = Albatross_cli.conn_metrics "unix"
let m = Vmm_core.conn_metrics "unix"
let jump _ interval influx =
Sys.(set_signal sigpipe Signal_ignore) ;

View File

@ -46,7 +46,7 @@ let rec wrap f arg =
Logs.err (fun m -> m "exception %s" (Printexc.to_string e)) ;
None
let vmmapi = Albatross_cli.conn_metrics "vmmapi"
let vmmapi = conn_metrics "vmmapi"
let remove_vmid t vmid =
Logs.info (fun m -> m "removing vmid %a" Vmm_core.Name.pp vmid) ;

View File

@ -7,7 +7,7 @@ let () =
(library
(name albatross_stats)
(public_name albatross.stats)
(libraries albatross albatross.cli)
(libraries albatross)
(wrapped false)
(c_names albatross_stats_stubs)
(modules albatross_stats_pure))