diff --git a/src/lib_p2p/p2p.ml b/src/lib_p2p/p2p.ml index dce966f55c5e06f5bafe9122e334169a9d56aa3f..6c7015bb705308fc6ee6263305f3d07c8651b3e4 100644 --- a/src/lib_p2p/p2p.ml +++ b/src/lib_p2p/p2p.ml @@ -225,7 +225,7 @@ module Real = struct create_maintenance_worker limits pool connect_handler config triggers log in let* welcome = may_create_welcome_worker config limits connect_handler in - P2p_metrics.collect pool ; + P2p_metrics_collectors.collect pool ; return { config; @@ -322,16 +322,8 @@ module Real = struct let peer_id = (P2p_conn.info conn).peer_id in let* () = match msg with - | Ok _ -> - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4874 - - the counter should be moved to P2p_conn instead *) - Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_received ; - Events.(emit message_read) peer_id - | Error _ -> - Prometheus.Counter.inc_one - P2p_metrics.Messages.user_message_received_error ; - Events.(emit message_read_error) peer_id + | Ok _ -> Events.(emit message_read) peer_id + | Error _ -> Events.(emit message_read_error) peer_id in return msg @@ -367,10 +359,6 @@ module Real = struct match r with | Ok () -> let peer_id = (P2p_conn.info conn).peer_id in - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4874 - - the counter should be moved to P2p_conn instead *) - Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_sent ; Events.(emit message_sent) peer_id | Error trace -> Events.(emit sending_message_error) @@ -381,10 +369,6 @@ module Real = struct let try_send _net conn v = match P2p_conn.write_now conn v with | Ok v -> - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4874 - - the counter should be moved to P2p_conn instead *) - Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_sent ; Events.(emit__dont_wait__use_with_care message_trysent) (P2p_conn.info conn).peer_id ; v diff --git a/src/lib_p2p/p2p_conn.ml b/src/lib_p2p/p2p_conn.ml index 188220d9d0aa08dd6ed7188b42046c8d07b1751a..70be6cea1db612e948d0642f20bb127beeb4ed02 100644 --- a/src/lib_p2p/p2p_conn.ml +++ b/src/lib_p2p/p2p_conn.ml @@ -50,6 +50,7 @@ let rec worker_loop (t : ('msg, 'peer, 'conn) t) callback = let* r = protect ~canceler:t.canceler (fun () -> P2p_socket.read t.conn) in match r with | Ok (_, Bootstrap) -> ( + Prometheus.Counter.inc_one P2p_metrics.Messages.bootstrap_received ; let* () = Events.(emit bootstrap_received) t.peer_id in if t.disable_peer_discovery then worker_loop t callback else @@ -67,6 +68,7 @@ let rec worker_loop (t : ('msg, 'peer, 'conn) t) callback = | Ok () -> worker_loop t callback | Error _ -> Error_monad.cancel_with_exceptions t.canceler) | Ok (_, Advertise points) -> + Prometheus.Counter.inc_one P2p_metrics.Messages.advertise_received ; let* () = Events.(emit advertise_received) (t.peer_id, points) in let* () = if t.disable_peer_discovery then return_unit @@ -78,6 +80,7 @@ let rec worker_loop (t : ('msg, 'peer, 'conn) t) callback = in worker_loop t callback | Ok (_, Swap_request (point, peer)) -> + Prometheus.Counter.inc_one P2p_metrics.Messages.swap_request_received ; let* () = Events.(emit swap_request_received) (t.peer_id, point, peer) in let request_info = P2p_answerer.{last_sent_swap_request = t.last_sent_swap_request} @@ -85,6 +88,7 @@ let rec worker_loop (t : ('msg, 'peer, 'conn) t) callback = let* () = callback.swap_request request_info point peer in worker_loop t callback | Ok (_, Swap_ack (point, peer)) -> + Prometheus.Counter.inc_one P2p_metrics.Messages.swap_ack_received ; let* () = Events.(emit swap_ack_received) (t.peer_id, point, peer) in let request_info = P2p_answerer.{last_sent_swap_request = t.last_sent_swap_request} @@ -92,6 +96,7 @@ let rec worker_loop (t : ('msg, 'peer, 'conn) t) callback = let* () = callback.swap_ack request_info point peer in worker_loop t callback | Ok (size, Message msg) -> + Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_received ; let request_info = P2p_answerer.{last_sent_swap_request = t.last_sent_swap_request} in @@ -116,12 +121,17 @@ let shutdown t = w let write_swap_ack t point peer_id = - P2p_socket.write_now t.conn (Swap_ack (point, peer_id)) + let result = P2p_socket.write_now t.conn (Swap_ack (point, peer_id)) in + Prometheus.Counter.inc_one P2p_metrics.Messages.swap_ack_sent ; + result let write_advertise t points = if t.disable_peer_discovery then Result_syntax.tzfail P2p_errors.Peer_discovery_disabled - else P2p_socket.write_now t.conn (Advertise points) + else + let result = P2p_socket.write_now t.conn (Advertise points) in + Prometheus.Counter.inc_one P2p_metrics.Messages.advertise_sent ; + result let create ~conn ~point_info ~peer_info ~messages ~canceler ~greylister ~callback ~disable_peer_discovery negotiated_version = @@ -184,7 +194,10 @@ let read t = (s, (P2p_socket.info t.conn).peer_id) in return_ok msg) - pipe_exn_handler + (fun e -> + Prometheus.Counter.inc_one + P2p_metrics.Messages.user_message_received_error ; + pipe_exn_handler e) let is_readable t = let open Lwt_result_syntax in @@ -194,9 +207,15 @@ let is_readable t = return_unit) pipe_exn_handler -let write t msg = P2p_socket.write t.conn (Message msg) +let write t msg = + let result = P2p_socket.write t.conn (Message msg) in + Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_sent ; + result -let write_sync t msg = P2p_socket.write_sync t.conn (Message msg) +let write_sync t msg = + let result = P2p_socket.write_sync t.conn (Message msg) in + Prometheus.Counter.inc_one P2p_metrics.Messages.user_message_sent ; + result let encode t msg = P2p_socket.encode t.conn (Message msg) @@ -206,13 +225,18 @@ let write_now t msg = P2p_socket.write_now t.conn (Message msg) let write_swap_request t point peer_id = t.last_sent_swap_request <- Some (Time.System.now (), peer_id) ; - P2p_socket.write_now t.conn (Swap_request (point, peer_id)) + let result = P2p_socket.write_now t.conn (Swap_request (point, peer_id)) in + Prometheus.Counter.inc_one P2p_metrics.Messages.swap_request_sent ; + result let write_bootstrap t = if t.disable_peer_discovery then ( Events.(emit__dont_wait__use_with_care peer_discovery_disabled) () ; Result_syntax.return_false) - else P2p_socket.write_now t.conn Bootstrap + else + let result = P2p_socket.write_now t.conn Bootstrap in + Prometheus.Counter.inc_one P2p_metrics.Messages.bootstrap_sent ; + result let stat t = P2p_socket.stat t.conn diff --git a/src/lib_p2p/p2p_maintenance.ml b/src/lib_p2p/p2p_maintenance.ml index bf7040dff3f3bef6ee9aeb3e120e695125dd708d..4d48278ff5169cb7c5280d0886fe158861e727de 100644 --- a/src/lib_p2p/p2p_maintenance.ml +++ b/src/lib_p2p/p2p_maintenance.ml @@ -69,7 +69,6 @@ let broadcast_bootstrap_msg t = match P2p_peer_state.get peer_info with | Running {data = conn; _} -> if not (P2p_conn.private_node conn) then ( - Prometheus.Counter.inc_one P2p_metrics.Messages.bootstrap_sent ; ignore (P2p_conn.write_bootstrap conn) ; t.log (Bootstrap_sent {source = peer_id})) | _ -> ()) @@ -81,7 +80,6 @@ let send_swap_request t = | Some (proposed_point, proposed_peer_id, recipient) -> let recipient_peer_id = (P2p_conn.info recipient).peer_id in t.log (Swap_request_sent {source = recipient_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_request_sent ; ignore (P2p_conn.write_swap_request recipient proposed_point proposed_peer_id) diff --git a/src/lib_p2p/p2p_metrics.ml b/src/lib_p2p/p2p_metrics.ml index 19bb0a4a1b74db253709296bbacade077a73c222..b6c3dd88e23488ce64453a99e5ea6b2fa1618ce9 100644 --- a/src/lib_p2p/p2p_metrics.ml +++ b/src/lib_p2p/p2p_metrics.ml @@ -27,24 +27,6 @@ let namespace = Tezos_version.Node_version.namespace let subsystem = "p2p" -let metric ~help ~component ~name collector = - let info = - { - Prometheus.MetricInfo.name = - Prometheus.MetricName.v - (String.concat "_" [namespace; subsystem; component; name]); - help; - metric_type = Gauge; - label_names = []; - } - in - let collect () = - Prometheus.LabelSetMap.singleton - [] - [Prometheus.Sample_set.sample (collector ())] - in - (info, collect) - (* we add this function to impose the correct namespace *) let metric_counter ~component ~help ~name () = Prometheus.Counter.v @@ -53,216 +35,6 @@ let metric_counter ~component ~help ~name () = ~subsystem (String.concat "_" [component; name]) -let add_metric (info, collector) = - Prometheus.CollectorRegistry.(register default) info collector - -module Connections = struct - let component = "connections" - - module Stats = struct - let active = ref 0. - - let incoming = ref 0. - - let outgoing = ref 0. - - let private_ = ref 0. - - let zero () = - active := 0. ; - incoming := 0. ; - outgoing := 0. ; - private_ := 0. - end - - let active_connections = - metric - ~help:"Number of active connections" - ~component - ~name:"active" - (fun () -> !Stats.active) - - let incoming_connections = - metric - ~help:"Number of incoming connections" - ~component - ~name:"incoming" - (fun () -> !Stats.incoming) - - let outgoing_connections = - metric - ~help:"Number of outgoing connections" - ~component - ~name:"outgoing" - (fun () -> !Stats.outgoing) - - let private_connections = - metric - ~help:"Number of private connections" - ~component - ~name:"private" - (fun () -> !Stats.private_) - - let metrics = - [ - active_connections; - incoming_connections; - outgoing_connections; - private_connections; - ] - - let () = List.iter add_metric metrics - - let collect pool = - Stats.zero () ; - P2p_pool.Connection.iter - (fun _ connection -> - if P2p_conn.private_node connection then - Stats.private_ := !Stats.private_ +. 1. ; - Stats.active := !Stats.active +. 1. ; - match P2p_conn.info connection with - | {incoming = true; _} -> Stats.incoming := !Stats.incoming +. 1. - | {incoming = false; _} -> Stats.outgoing := !Stats.outgoing +. 1.) - pool -end - -module Peers = struct - let component = "peers" - - module Stats = struct - let accepted = ref 0. - - let running = ref 0. - - let disconnected = ref 0. - - let zero () = - accepted := 0. ; - running := 0. ; - disconnected := 0. - end - - let accepted_peers = - metric - ~help:"Number of accepted connections" - ~component - ~name:"accepted" - (fun () -> !Stats.accepted) - - let running_peers = - metric ~help:"Number of running peers" ~component ~name:"running" (fun () -> - !Stats.running) - - let disconnected_peers = - metric - ~help:"Number of disconnected peers" - ~component - ~name:"disconnected" - (fun () -> !Stats.disconnected) - - let metrics = [accepted_peers; running_peers; disconnected_peers] - - let () = List.iter add_metric metrics - - let collect pool = - Stats.zero () ; - P2p_pool.Peers.iter_known - (fun _ info -> - match info with - | info when P2p_peer_state.is_accepted info -> - Stats.accepted := !Stats.accepted +. 1. - | info when P2p_peer_state.is_disconnected info -> - Stats.disconnected := !Stats.disconnected +. 1. - | info when P2p_peer_state.is_running info -> - Stats.running := !Stats.running +. 1. - | _ -> ()) - pool -end - -module Points = struct - let component = "points" - - module Stats = struct - let trusted = ref 0. - - let greylisted = ref 0. - - let accepted = ref 0. - - let running = ref 0. - - let disconnected = ref 0. - - let zero () = - trusted := 0. ; - greylisted := 0. ; - accepted := 0. ; - running := 0. ; - disconnected := 0. - end - - let trusted_points = - metric - ~help:"Number of trusted points" - ~component - ~name:"trusted" - (fun () -> !Stats.trusted) - - let greylisted_points = - metric - ~help:"Number of greylisted points" - ~component - ~name:"greylisted" - (fun () -> !Stats.greylisted) - - let accepted_points = - metric - ~help:"Number of accepted points" - ~component - ~name:"accepted" - (fun () -> !Stats.accepted) - - let running_points = - metric - ~help:"Number of running points" - ~component - ~name:"running" - (fun () -> !Stats.running) - - let disconnected_points = - metric - ~help:"Number of disconnected points" - ~component - ~name:"disconnected" - (fun () -> !Stats.disconnected) - - let metrics = - [ - trusted_points; - greylisted_points; - accepted_points; - running_points; - disconnected_points; - ] - - let () = List.iter add_metric metrics - - let collect pool = - Stats.zero () ; - P2p_pool.Points.iter_known - (fun _ info -> - if P2p_point_state.is_accepted info then - Stats.accepted := !Stats.accepted +. 1. - else if P2p_point_state.is_disconnected info then - Stats.disconnected := !Stats.disconnected +. 1. - else if P2p_point_state.is_running info then - Stats.running := !Stats.running +. 1. ; - match P2p_point_state.Info.reconnection_time info with - | Some _ -> Stats.greylisted := !Stats.greylisted +. 1. - | _ -> ()) - pool -end - module Messages = struct let component = "messages" @@ -341,9 +113,3 @@ module Swap = struct let fail = metric_counter ~help:"Number of failed swap" ~name:"fail" () end - -let collect pool = - Prometheus.CollectorRegistry.(register_pre_collect default) (fun () -> - Connections.collect pool ; - Peers.collect pool ; - Points.collect pool) diff --git a/src/lib_p2p/p2p_metrics.mli b/src/lib_p2p/p2p_metrics.mli index 10fed79b171eda80bb339a965ddd4fd5ca386d9c..c3c4bc3c4833e490e3f8458a05c87518437237d7 100644 --- a/src/lib_p2p/p2p_metrics.mli +++ b/src/lib_p2p/p2p_metrics.mli @@ -75,6 +75,3 @@ module Swap : sig (** failed swaps counter *) val fail : Counter.t end - -(** [collect pool] registers metrics collections of [pool] *) -val collect : ('msg, 'peer, 'conn) P2p_pool.t -> unit diff --git a/src/lib_p2p/p2p_metrics_collectors.ml b/src/lib_p2p/p2p_metrics_collectors.ml new file mode 100644 index 0000000000000000000000000000000000000000..7919f684b25b1d462804b320b3bf1dfc3b480456 --- /dev/null +++ b/src/lib_p2p/p2p_metrics_collectors.ml @@ -0,0 +1,262 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +let namespace = Tezos_version.Node_version.namespace + +let subsystem = "p2p" + +let metric ~help ~component ~name collector = + let info = + { + Prometheus.MetricInfo.name = + Prometheus.MetricName.v + (String.concat "_" [namespace; subsystem; component; name]); + help; + metric_type = Gauge; + label_names = []; + } + in + let collect () = + Prometheus.LabelSetMap.singleton + [] + [Prometheus.Sample_set.sample (collector ())] + in + (info, collect) + +let add_metric (info, collector) = + Prometheus.CollectorRegistry.(register default) info collector + +module Connections = struct + let component = "connections" + + module Stats = struct + let active = ref 0. + + let incoming = ref 0. + + let outgoing = ref 0. + + let private_ = ref 0. + + let zero () = + active := 0. ; + incoming := 0. ; + outgoing := 0. ; + private_ := 0. + end + + let active_connections = + metric + ~help:"Number of active connections" + ~component + ~name:"active" + (fun () -> !Stats.active) + + let incoming_connections = + metric + ~help:"Number of incoming connections" + ~component + ~name:"incoming" + (fun () -> !Stats.incoming) + + let outgoing_connections = + metric + ~help:"Number of outgoing connections" + ~component + ~name:"outgoing" + (fun () -> !Stats.outgoing) + + let private_connections = + metric + ~help:"Number of private connections" + ~component + ~name:"private" + (fun () -> !Stats.private_) + + let metrics = + [ + active_connections; + incoming_connections; + outgoing_connections; + private_connections; + ] + + let () = List.iter add_metric metrics + + let collect pool = + Stats.zero () ; + P2p_pool.Connection.iter + (fun _ connection -> + if P2p_conn.private_node connection then + Stats.private_ := !Stats.private_ +. 1. ; + Stats.active := !Stats.active +. 1. ; + match P2p_conn.info connection with + | {incoming = true; _} -> Stats.incoming := !Stats.incoming +. 1. + | {incoming = false; _} -> Stats.outgoing := !Stats.outgoing +. 1.) + pool +end + +module Peers = struct + let component = "peers" + + module Stats = struct + let accepted = ref 0. + + let running = ref 0. + + let disconnected = ref 0. + + let zero () = + accepted := 0. ; + running := 0. ; + disconnected := 0. + end + + let accepted_peers = + metric + ~help:"Number of accepted connections" + ~component + ~name:"accepted" + (fun () -> !Stats.accepted) + + let running_peers = + metric ~help:"Number of running peers" ~component ~name:"running" (fun () -> + !Stats.running) + + let disconnected_peers = + metric + ~help:"Number of disconnected peers" + ~component + ~name:"disconnected" + (fun () -> !Stats.disconnected) + + let metrics = [accepted_peers; running_peers; disconnected_peers] + + let () = List.iter add_metric metrics + + let collect pool = + Stats.zero () ; + P2p_pool.Peers.iter_known + (fun _ info -> + match info with + | info when P2p_peer_state.is_accepted info -> + Stats.accepted := !Stats.accepted +. 1. + | info when P2p_peer_state.is_disconnected info -> + Stats.disconnected := !Stats.disconnected +. 1. + | info when P2p_peer_state.is_running info -> + Stats.running := !Stats.running +. 1. + | _ -> ()) + pool +end + +module Points = struct + let component = "points" + + module Stats = struct + let trusted = ref 0. + + let greylisted = ref 0. + + let accepted = ref 0. + + let running = ref 0. + + let disconnected = ref 0. + + let zero () = + trusted := 0. ; + greylisted := 0. ; + accepted := 0. ; + running := 0. ; + disconnected := 0. + end + + let trusted_points = + metric + ~help:"Number of trusted points" + ~component + ~name:"trusted" + (fun () -> !Stats.trusted) + + let greylisted_points = + metric + ~help:"Number of greylisted points" + ~component + ~name:"greylisted" + (fun () -> !Stats.greylisted) + + let accepted_points = + metric + ~help:"Number of accepted points" + ~component + ~name:"accepted" + (fun () -> !Stats.accepted) + + let running_points = + metric + ~help:"Number of running points" + ~component + ~name:"running" + (fun () -> !Stats.running) + + let disconnected_points = + metric + ~help:"Number of disconnected points" + ~component + ~name:"disconnected" + (fun () -> !Stats.disconnected) + + let metrics = + [ + trusted_points; + greylisted_points; + accepted_points; + running_points; + disconnected_points; + ] + + let () = List.iter add_metric metrics + + let collect pool = + Stats.zero () ; + P2p_pool.Points.iter_known + (fun _ info -> + if P2p_point_state.is_accepted info then + Stats.accepted := !Stats.accepted +. 1. + else if P2p_point_state.is_disconnected info then + Stats.disconnected := !Stats.disconnected +. 1. + else if P2p_point_state.is_running info then + Stats.running := !Stats.running +. 1. ; + match P2p_point_state.Info.reconnection_time info with + | Some _ -> Stats.greylisted := !Stats.greylisted +. 1. + | _ -> ()) + pool +end + +let collect pool = + Prometheus.CollectorRegistry.(register_pre_collect default) (fun () -> + Connections.collect pool ; + Peers.collect pool ; + Points.collect pool) diff --git a/src/lib_p2p/p2p_metrics_collectors.mli b/src/lib_p2p/p2p_metrics_collectors.mli new file mode 100644 index 0000000000000000000000000000000000000000..4443fd05ada71f97ea65e272c97c92d48c29fa7a --- /dev/null +++ b/src/lib_p2p/p2p_metrics_collectors.mli @@ -0,0 +1,27 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** [collect pool] registers metrics collections of [pool] *) +val collect : ('msg, 'peer, 'conn) P2p_pool.t -> unit diff --git a/src/lib_p2p/p2p_protocol.ml b/src/lib_p2p/p2p_protocol.ml index ab3fd3baeaf294bf8d54530a0402b081cb7fc701..5f67dae27233a82674a4401ab9bc6abc68aba59b 100644 --- a/src/lib_p2p/p2p_protocol.ml +++ b/src/lib_p2p/p2p_protocol.ml @@ -42,19 +42,15 @@ let message conn _request size msg = module Private_answerer = struct let advertise conn _request _points = - Prometheus.Counter.inc_one P2p_metrics.Messages.advertise_received ; Events.(emit private_node_new_peers) conn.peer_id let bootstrap conn _request = - Prometheus.Counter.inc_one P2p_metrics.Messages.bootstrap_received ; Lwt_result.ok @@ Events.(emit private_node_peers_request) conn.peer_id let swap_request conn _request _new_point _peer = - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_request_received ; Events.(emit private_node_swap_request) conn.peer_id let swap_ack conn _request _point _peer_id = - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_ack_received ; Events.(emit private_node_swap_ack) conn.peer_id let create conn = @@ -75,7 +71,6 @@ module Default_answerer = struct let log = config.log in let source_peer_id = conn.peer_id in log (Advertise_received {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.advertise_received ; P2p_pool.register_list_of_new_points ~medium:"advertise" ~source:conn.peer_id @@ -87,7 +82,6 @@ module Default_answerer = struct let log = config.log in let source_peer_id = conn.peer_id in log (Bootstrap_received {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.bootstrap_received ; if conn.is_private then let*! () = Events.(emit private_node_request) conn.peer_id in return_unit @@ -101,7 +95,6 @@ module Default_answerer = struct match conn.write_advertise points with | Ok true -> log (Advertise_sent {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.advertise_sent ; return_unit | Ok false -> (* TODO: https://gitlab.com/tezos/tezos/-/issues/4594 @@ -141,7 +134,6 @@ module Default_answerer = struct let connect = config.connect in let log = config.log in log (Swap_ack_received {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_ack_received ; let do_swap = let open Option_syntax in let* _ = config.swap_linger (* Don't answer if swap is disabled. *) in @@ -176,7 +168,6 @@ module Default_answerer = struct let connect = config.connect in let log = config.log in log (Swap_request_received {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_request_received ; let do_swap = let* swap_linger = config.swap_linger |> Option.to_result ~none:`Swap_is_disabled @@ -232,7 +223,6 @@ module Default_answerer = struct fail @@ `Couldnt_write_swap_ack "Buffer is full. Message dropped." in log (Swap_ack_sent {source = source_peer_id}) ; - Prometheus.Counter.inc_one P2p_metrics.Messages.swap_ack_sent ; return @@ swap config pool source_peer_id ~connect proposed_peer_id new_point in