diff --git a/CHANGES.rst b/CHANGES.rst index 4f36d307f7f85e14de7ac1b42c45723a5ef962ef..96c6ce1387736d0229f5173684cace7b4288d6c3 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 ------------- diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index f2001be9b2a1f95785168ee18ce0a98955f15243..f014a9cf598245a947ab7e064dd478fe656b98a1 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 4fc930596f75dbe8d53a44d2bfe220d31af84507..a5d61e40e9948a81addb40bd6b1c4c6502f7f4e1 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 f2c5c722ef43f8d72f858e560c2d3b18c82354fe..6f2d380918ed305b6d3729fc8a57585c11b0b166 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 435698b382b64dd9ef0d543a5ec70ac6a57522d7..df66c6a5e034ba5ec33c2115ee1aca9f0640a0d5 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 f648c560607d4f25b79fd85d99342fb7e4a4e8e8..38a999858ef28c13d680c49127e7f8164d72ec23 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 89ce9e04a8d796ad9b3b11d39b1012196255d8bd..1d04bfe1005c7e8c1cc23740c0b698dbe2a44d18 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;