From f2bdf3cb7fa5fe103f1e9c89e1b8cd7517b88d82 Mon Sep 17 00:00:00 2001 From: Sergey Prokhorov Date: Thu, 9 Apr 2026 00:48:02 +0200 Subject: [PATCH] Fix metrics call to ranch:info() Bug was introduced when we upgraded to ranch 2.x.x in fc9ec1d326579b592fd111ac28811fdbf47e00f7 --- README.md | 2 +- src/mtp_metric.erl | 2 +- src/mtproto_proxy_app.erl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ac14658..cbbcdcf 100644 --- a/README.md +++ b/README.md @@ -808,5 +808,5 @@ Helpers Number of connections ```bash -/opt/mtp_proxy/bin/mtp_proxy eval 'lists:sum([proplists:get_value(all_connections, L) || {_, L} <- ranch:info()]).' +/opt/mtp_proxy/bin/mtp_proxy eval 'lists:sum([maps:get(all_connections, L) || {_, L} <- maps:to_list(ranch:info())]).' ``` diff --git a/src/mtp_metric.erl b/src/mtp_metric.erl index 5fec7cb..0ea8aed 100644 --- a/src/mtp_metric.erl +++ b/src/mtp_metric.erl @@ -98,7 +98,7 @@ passive_metrics() -> | [{gauge, [?APP, connections, count], "Count of ranch connections", - [{#{listener => H}, proplists:get_value(all_connections, P)} + [{#{listener => H}, maps:get(all_connections, P)} || {H, P} <- mtproto_proxy_app:mtp_listeners()]}] ]. -spec active_metrics() -> [{metric_type(), metric_name(), metric_doc(), Opts}] diff --git a/src/mtproto_proxy_app.erl b/src/mtproto_proxy_app.erl index 5102838..46b2dea 100644 --- a/src/mtproto_proxy_app.erl +++ b/src/mtproto_proxy_app.erl @@ -92,7 +92,7 @@ diff_env(NewEnv, OldEnv) -> %% @doc List of ranch listeners running mtproto_proxy --spec mtp_listeners() -> [tuple()]. +-spec mtp_listeners() -> [{ranch:ref(), #{atom() => term()}}]. mtp_listeners() -> maps:to_list( maps:filter(