mirror of
https://github.com/seriyps/mtproto_proxy.git
synced 2026-08-04 15:19:47 +00:00
Include dc_id to migration metric
This is to see which DCs trigger migrations more often. In UI should be divided by number of clients of DC
This commit is contained in:
parent
16abd21927
commit
3c29fa31e5
2 changed files with 7 additions and 6 deletions
|
|
@ -180,7 +180,7 @@ handle_cast({close_ext, Down}, #state{down = Down, sock = USock, transport = UTr
|
||||||
?LOG_DEBUG("asked to close connection by downstream"),
|
?LOG_DEBUG("asked to close connection by downstream"),
|
||||||
ok = UTrans:close(USock),
|
ok = UTrans:close(USock),
|
||||||
{stop, normal, S#state{down = undefined}};
|
{stop, normal, S#state{down = undefined}};
|
||||||
handle_cast({migrate, OldDown}, #state{down = OldDown, dc_id = {_DcId, Pool},
|
handle_cast({migrate, OldDown}, #state{down = OldDown, dc_id = {DcId, Pool},
|
||||||
codec = Codec, addr = Addr,
|
codec = Codec, addr = Addr,
|
||||||
ad_tag = AdTag, listener = Listener} = S) ->
|
ad_tag = AdTag, listener = Listener} = S) ->
|
||||||
{PacketLayerMod, _} = mtp_codec:info(packet, Codec),
|
{PacketLayerMod, _} = mtp_codec:info(packet, Codec),
|
||||||
|
|
@ -190,12 +190,12 @@ handle_cast({migrate, OldDown}, #state{down = OldDown, dc_id = {_DcId, Pool},
|
||||||
?LOG_DEBUG("Migration failed (~p), closing client", [Reason]),
|
?LOG_DEBUG("Migration failed (~p), closing client", [Reason]),
|
||||||
true = is_atom(Reason),
|
true = is_atom(Reason),
|
||||||
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
||||||
#{labels => [Listener, Reason]}),
|
#{labels => [Listener, DcId, Reason]}),
|
||||||
{stop, normal, S#state{down = undefined}};
|
{stop, normal, S#state{down = undefined}};
|
||||||
NewDown ->
|
NewDown ->
|
||||||
?LOG_DEBUG("Migrated from ~p to ~p", [OldDown, NewDown]),
|
?LOG_DEBUG("Migrated from ~p to ~p", [OldDown, NewDown]),
|
||||||
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
||||||
#{labels => [Listener, ok]}),
|
#{labels => [Listener, DcId, ok]}),
|
||||||
{noreply, S#state{down = NewDown}}
|
{noreply, S#state{down = NewDown}}
|
||||||
end;
|
end;
|
||||||
handle_cast({migrate, _StaleDown}, S) ->
|
handle_cast({migrate, _StaleDown}, S) ->
|
||||||
|
|
@ -639,7 +639,7 @@ up_send_raw(Data, #state{sock = Sock,
|
||||||
end
|
end
|
||||||
end, #{labels => [Listener]}).
|
end, #{labels => [Listener]}).
|
||||||
|
|
||||||
down_send(Packet, #state{down = Down, listener = Listener} = S) ->
|
down_send(Packet, #state{down = Down, listener = Listener, dc_id = Dc} = S) ->
|
||||||
%% ?LOG_DEBUG(">Down: ~p", [Packet]),
|
%% ?LOG_DEBUG(">Down: ~p", [Packet]),
|
||||||
case mtp_down_conn:send(Down, Packet) of
|
case mtp_down_conn:send(Down, Packet) of
|
||||||
ok ->
|
ok ->
|
||||||
|
|
@ -649,8 +649,9 @@ down_send(Packet, #state{down = Down, listener = Listener} = S) ->
|
||||||
{error, migrating} ->
|
{error, migrating} ->
|
||||||
%% DC connection is closing; this packet was never sent to TG.
|
%% DC connection is closing; this packet was never sent to TG.
|
||||||
%% Stop the handler so the client reconnects and resends.
|
%% Stop the handler so the client reconnects and resends.
|
||||||
|
{DcId, _} = Dc,
|
||||||
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
mtp_metric:count_inc([?APP, downstream_migration, total], 1,
|
||||||
#{labels => [Listener, mid_send]}),
|
#{labels => [Listener, DcId, mid_send]}),
|
||||||
throw({stop, normal, S})
|
throw({stop, normal, S})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,5 +192,5 @@ active_metrics() ->
|
||||||
|
|
||||||
{count, [?APP, downstream_migration, total],
|
{count, [?APP, downstream_migration, total],
|
||||||
"Count of client migrations to a new downstream connection",
|
"Count of client migrations to a new downstream connection",
|
||||||
#{labels => [listener, result]}}
|
#{labels => [listener, dc_id, result]}}
|
||||||
].
|
].
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue