From e79a2e5e1fd00c097df9bec3b4c67a2b156283ef Mon Sep 17 00:00:00 2001 From: Guillaume Bau Date: Tue, 1 Oct 2024 15:44:20 +0200 Subject: [PATCH 1/2] Dal/Node: disable metrics by default --- src/bin_dal_node/cli.ml | 2 +- src/bin_dal_node/configuration_file.ml | 10 +++++----- src/bin_dal_node/configuration_file.mli | 5 ++++- src/bin_dal_node/daemon.ml | 11 ++++++++++- src/bin_dal_node/event.ml | 16 ++++++++++++++++ src/bin_dal_node/main.ml | 3 ++- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index f2001be9b2a1..f014a9cf5982 100644 --- a/src/bin_dal_node/cli.ml +++ b/src/bin_dal_node/cli.ml @@ -230,7 +230,7 @@ module Term = struct "The TCP address and optionally the port of the node's metrics server. \ The default address is 0.0.0.0. The default port is 11733." in - let default_port = Configuration_file.default.metrics_addr |> snd in + let default_port = Configuration_file.default_metrics_port in Arg.( value & opt (some (p2p_point_arg ~default_port)) None diff --git a/src/bin_dal_node/configuration_file.ml b/src/bin_dal_node/configuration_file.ml index 4fc930596f75..a5d61e40e994 100644 --- a/src/bin_dal_node/configuration_file.ml +++ b/src/bin_dal_node/configuration_file.ml @@ -71,7 +71,7 @@ type t = { expected_pow : float; network_name : string; endpoint : Uri.t; - metrics_addr : P2p_point.Id.t; + metrics_addr : P2p_point.Id.t option; profile : Profile_manager.t; history_mode : history_mode; version : int; @@ -121,7 +121,7 @@ let default = expected_pow = default_expected_pow; network_name = default_network_name; endpoint = default_endpoint; - metrics_addr = default_metrics_addr; + metrics_addr = None; history_mode = default_history_mode; profile = Profile_manager.empty; version = current_version; @@ -259,8 +259,8 @@ let encoding : t Data_encoding.t = (dft "metrics-addr" ~description:"The point for the DAL node metrics server" - P2p_point.Id.encoding - default_metrics_addr)) + (Encoding.option P2p_point.Id.encoding) + None)) (obj5 (dft "history_mode" @@ -429,7 +429,7 @@ let from_v0 v0 = expected_pow = v0.expected_pow; network_name = v0.network_name; endpoint = v0.endpoint; - metrics_addr = v0.metrics_addr; + metrics_addr = Some v0.metrics_addr; history_mode = v0.history_mode; profile = v0.profile; version = current_version; diff --git a/src/bin_dal_node/configuration_file.mli b/src/bin_dal_node/configuration_file.mli index f2c5c722ef43..6f2d380918ed 100644 --- a/src/bin_dal_node/configuration_file.mli +++ b/src/bin_dal_node/configuration_file.mli @@ -52,7 +52,7 @@ type t = { network_name : string; (** A string that identifies the network's name. E.g. dal-sandbox. *) endpoint : Uri.t; (** The endpoint of a Tezos L1 node. *) - metrics_addr : P2p_point.Id.t; + metrics_addr : P2p_point.Id.t option; (** The TCP address of the node's server used to export metrics. *) profile : Profile_manager.t; (** The profiles determining the topics of interest. *) @@ -66,6 +66,9 @@ type t = { (** [default] is the default configuration. *) val default : t +(** [default_metrics_port] is the default network port opened for metrics *) +val default_metrics_port : int + (** [store_path config] returns a path for the store *) val store_path : t -> string diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 435698b382b6..df66c6a5e034 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -1115,7 +1115,16 @@ let run ~data_dir ~configuration_override = in (* Starts the metrics *after* the amplificator fork, to avoid forked opened sockets *) - let*! _metrics_server = Metrics.launch config.metrics_addr in + let* () = + match config.metrics_addr with + | None -> + let*! () = Event.(emit metrics_server_not_starting ()) in + return_unit + | Some metrics_addr -> + let*! () = Event.(emit metrics_server_starting metrics_addr) in + let*! _metrics_server = Metrics.launch metrics_addr in + return_unit + in (* Set value size hooks. *) Value_size_hooks.set_share_size (Cryptobox.Internal_for_tests.encoded_share_size cryptobox) ; diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index f648c560607d..38a999858ef2 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -373,6 +373,22 @@ let rpc_server_is_ready = ~level:Notice ("point", P2p_point.Id.encoding) +let metrics_server_starting = + declare_1 + ~section:(section @ ["metrics"]) + ~name:"metrics_service_start" + ~msg:"Starting metrics service at {endpoint}" + ~level:Notice + ("endpoint", P2p_point.Id.encoding) + +let metrics_server_not_starting = + declare_0 + ~section:(section @ ["metrics"]) + ~name:"metrics_service_no_start" + ~msg:"metrics service not enabled" + ~level:Notice + () + let metrics_server_is_ready = let open Internal_event.Simple in declare_2 diff --git a/src/bin_dal_node/main.ml b/src/bin_dal_node/main.ml index 89ce9e04a8d7..1d04bfe1005c 100644 --- a/src/bin_dal_node/main.ml +++ b/src/bin_dal_node/main.ml @@ -60,7 +60,8 @@ let merge expected_pow = Option.value ~default:configuration.expected_pow expected_pow; endpoint = Option.value ~default:configuration.endpoint endpoint; profile; - metrics_addr = Option.value ~default:configuration.metrics_addr metrics_addr; + (* metrics are disabled unless a metrics_addr option is specified *) + metrics_addr; peers = peers @ configuration.peers; history_mode = Option.value ~default:configuration.history_mode history_mode; service_name = Option.either service_name configuration.service_name; -- GitLab From df0f23148729600e59ad130eac87b482817155d6 Mon Sep 17 00:00:00 2001 From: Guillaume Bau Date: Wed, 2 Oct 2024 18:01:55 +0200 Subject: [PATCH 2/2] Changes: update dal changelog (breaking config file) --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 4f36d307f7f8..96c6ce138773 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -64,5 +64,11 @@ Data Availability Layer (DAL) DAL node ~~~~~~~~ +- **Breaking_change** The configuration value ``metrics-addr`` is now an option. + It should not break unless the value differs from the default value + (``0.0.0.0:11733``). The new default value is ``None``, so no metrics are + exported by default. + + Miscellaneous ------------- -- GitLab