Add session_lifetime metric

This commit is contained in:
Сергей Прохоров 2018-10-06 20:49:28 +02:00
parent 56d8bac4ea
commit ea6c692ae5
No known key found for this signature in database
GPG key ID: 1C570244E4EF3337

View file

@ -168,8 +168,12 @@ handle_info(Other, S) ->
lager:warning("Unexpected handle_info ~p", [Other]),
{noreply, S}.
terminate(_Reason, #state{}) ->
terminate(_Reason, #state{started_at = Started}) ->
mtp_metric:count_inc([?APP, in_connection_closed, total], 1, #{}),
Lifetime = erlang:system_time(millisecond) - Started,
metric:histogram_observe(
[?APP, session_lifetime, seconds],
erlang:convert_time_unit(Lifetime, millisecond, native), #{}),
lager:debug("terminate ~p", [_Reason]),
ok.