upgrade to mirage4, drop usage of OS.MM.malloc_metrics
This commit is contained in:
parent
3bf6ceb432
commit
7b78a528cc
3 changed files with 14 additions and 12 deletions
|
@ -16,8 +16,7 @@ depends: [
|
||||||
"metrics-influx" {>= "0.2.0"}
|
"metrics-influx" {>= "0.2.0"}
|
||||||
"mirage-time" {>= "2.0.0"}
|
"mirage-time" {>= "2.0.0"}
|
||||||
"tcpip" {>= "7.0.0"}
|
"tcpip" {>= "7.0.0"}
|
||||||
"mirage-solo5" {>= "0.6.4" & < "0.7.0"}
|
"mirage-solo5" {>= "0.7.0"}
|
||||||
"ocaml-freestanding" {>= "0.4.5"}
|
|
||||||
"mirage-runtime"
|
"mirage-runtime"
|
||||||
"memtrace-mirage" {>= "0.2.1.2.2"}
|
"memtrace-mirage" {>= "0.2.1.2.2"}
|
||||||
"mirage-clock" {>= "4.0.0"}
|
"mirage-clock" {>= "4.0.0"}
|
||||||
|
|
|
@ -31,11 +31,12 @@ let counter_metrics ~f name =
|
||||||
|
|
||||||
let vmname = Metrics.field ~doc:"name of the virtual machine" "vm" Metrics.String
|
let vmname = Metrics.field ~doc:"name of the virtual machine" "vm" Metrics.String
|
||||||
|
|
||||||
let memory_metrics ~tags =
|
let memory_metrics ~quick ~tags =
|
||||||
let open Metrics in
|
let open Metrics in
|
||||||
let doc = "Memory counters" in
|
let doc = "Memory counters" in
|
||||||
|
let stat = Solo5_os.Memory.(if quick then quick_stat else stat) in
|
||||||
let data () =
|
let data () =
|
||||||
let stat = OS.Memory.quick_stat () in
|
let stat = stat () in
|
||||||
Data.v
|
Data.v
|
||||||
[ uint "memory heap words" stat.heap_words
|
[ uint "memory heap words" stat.heap_words
|
||||||
; uint "memory live words" stat.live_words
|
; uint "memory live words" stat.live_words
|
||||||
|
@ -264,8 +265,8 @@ module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6)
|
||||||
Lwt.return_unit) >>= fun () ->
|
Lwt.return_unit) >>= fun () ->
|
||||||
S.TCP.close f)
|
S.TCP.close f)
|
||||||
|
|
||||||
let create ?(interval = 10) ?hostname dst ?(port = 8094) ?(listen_port = 2323)
|
let create ?(interval = 10) ?(quick = true) ?hostname dst ?(port = 8094)
|
||||||
?(memtrace_port = 4242) ?(sampling_rate = 1e-4) stack =
|
?(listen_port = 2323) ?(memtrace_port = 4242) ?(sampling_rate = 1e-4) stack =
|
||||||
S.TCP.listen (S.tcp stack) ~port:memtrace_port
|
S.TCP.listen (S.tcp stack) ~port:memtrace_port
|
||||||
(fun f ->
|
(fun f ->
|
||||||
(* only allow a single tracing client *)
|
(* only allow a single tracing client *)
|
||||||
|
@ -285,8 +286,7 @@ module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6)
|
||||||
Metrics.set_reporter reporter;
|
Metrics.set_reporter reporter;
|
||||||
Metrics.enable_all ();
|
Metrics.enable_all ();
|
||||||
Metrics_lwt.init_periodic (fun () -> T.sleep_ns (Duration.of_sec interval));
|
Metrics_lwt.init_periodic (fun () -> T.sleep_ns (Duration.of_sec interval));
|
||||||
Metrics_lwt.periodically (OS.MM.malloc_metrics ~tags:Metrics.Tags.[])[@warning "-3"];
|
Metrics_lwt.periodically (memory_metrics ~quick ~tags:Metrics.Tags.[]);
|
||||||
Metrics_lwt.periodically (memory_metrics ~tags:Metrics.Tags.[]);
|
|
||||||
let host = match hostname with None -> [] | Some host -> [vmname host] in
|
let host = match hostname with None -> [] | Some host -> [vmname host] in
|
||||||
Lwt.async (timer_loop get_cache host interval stack (dst, port));
|
Lwt.async (timer_loop get_cache host interval stack (dst, port));
|
||||||
create_listener stack listen_port
|
create_listener stack listen_port
|
||||||
|
|
|
@ -7,14 +7,17 @@ val vmname : string -> Metrics.field
|
||||||
|
|
||||||
module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6) : sig
|
module Make (T : Mirage_time.S) (P : Mirage_clock.PCLOCK) (S : Tcpip.Stack.V4V6) : sig
|
||||||
|
|
||||||
val create : ?interval:int -> ?hostname:string -> Ipaddr.t -> ?port:int ->
|
val create : ?interval:int -> ?quick:bool -> ?hostname:string -> Ipaddr.t ->
|
||||||
?listen_port:int -> ?memtrace_port:int -> ?sampling_rate:float -> S.t -> unit
|
?port:int -> ?listen_port:int -> ?memtrace_port:int ->
|
||||||
(** [create ~interval ~hostname ip ~port ~listen_port ~memtrace_port ~sampling_rate stack]
|
?sampling_rate:float -> S.t -> unit
|
||||||
|
(** [create ~interval ~quick ~hostname ip ~port ~listen_port ~memtrace_port ~sampling_rate stack]
|
||||||
initiates monitoring on [stack] for the unikernel. The metrics are reported
|
initiates monitoring on [stack] for the unikernel. The metrics are reported
|
||||||
every [interval] (defaults to 10) seconds to [ip] on [port] (defaults to
|
every [interval] (defaults to 10) seconds to [ip] on [port] (defaults to
|
||||||
8094) via TCP using the influxd wire protocol. On [listen_port] (defaults
|
8094) via TCP using the influxd wire protocol. On [listen_port] (defaults
|
||||||
to 2323) a TCP connection can be initiated to adjust the log level and
|
to 2323) a TCP connection can be initiated to adjust the log level and
|
||||||
enable and disable metrics sources. On [memtrace_port] (defaults to 4242)
|
enable and disable metrics sources. On [memtrace_port] (defaults to 4242)
|
||||||
a single TCP client can connect simultaneously to receive a [Gc.Memprof]
|
a single TCP client can connect simultaneously to receive a [Gc.Memprof]
|
||||||
trace. The [sampling_rate] defaults to [1e-4]. *)
|
trace. The [sampling_rate] defaults to [1e-4]. If [quick] is provided
|
||||||
|
and [false] (defaults to [true]), [Solo5_os.Memory.stat] is used,
|
||||||
|
otherwise [Solo5_os.Memory.quick_stat] is used. *)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue