aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ranch.erl')
-rw-r--r--src/ranch.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index 4adb1d8..a83402d 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -420,7 +420,8 @@ listener_info(Ref, Pid) ->
transport => Transport,
transport_options => TransOpts,
protocol => Protocol,
- protocol_options => ProtoOpts
+ protocol_options => ProtoOpts,
+ metrics => metrics(Ref)
}.
-spec procs(ref(), acceptors | connections) -> [pid()].
@@ -447,6 +448,23 @@ procs1(ListenerSup, connections) ->
),
lists:flatten(Conns).
+-spec metrics(ref()) -> #{}.
+metrics(Ref) ->
+ Counters = ranch_server:get_stats_counters(Ref),
+ CounterInfo = counters:info(Counters),
+ NumCounters = maps:get(size, CounterInfo),
+ NumConnsSups = NumCounters div 2,
+ lists:foldl(
+ fun (Id, Acc) ->
+ Acc#{
+ {conns_sup, Id, accept} => counters:get(Counters, 2*Id-1),
+ {conns_sup, Id, terminate} => counters:get(Counters, 2*Id)
+ }
+ end,
+ #{},
+ lists:seq(1, NumConnsSups)
+ ).
+
-spec wait_for_connections
(ref(), '>' | '>=' | '==' | '=<', non_neg_integer()) -> ok;
(ref(), '<', pos_integer()) -> ok.