Merge pull request #12351 from HJianBo/improve-the-http-connector-logs
chore: improve http connector logs format
This commit is contained in:
commit
f7ae9ab489
|
@ -252,6 +252,7 @@ start_pool(PoolName, PoolOpts) ->
|
||||||
{error, {already_started, _}} ->
|
{error, {already_started, _}} ->
|
||||||
?SLOG(warning, #{
|
?SLOG(warning, #{
|
||||||
msg => "emqx_connector_on_start_already_started",
|
msg => "emqx_connector_on_start_already_started",
|
||||||
|
connector => PoolName,
|
||||||
pool_name => PoolName
|
pool_name => PoolName
|
||||||
}),
|
}),
|
||||||
ok;
|
ok;
|
||||||
|
@ -510,8 +511,8 @@ resolve_pool_worker(#{pool_name := PoolName} = State, Key) ->
|
||||||
on_get_channels(ResId) ->
|
on_get_channels(ResId) ->
|
||||||
emqx_bridge_v2:get_channels_for_connector(ResId).
|
emqx_bridge_v2:get_channels_for_connector(ResId).
|
||||||
|
|
||||||
on_get_status(_InstId, #{pool_name := PoolName, connect_timeout := Timeout} = State) ->
|
on_get_status(InstId, #{pool_name := InstId, connect_timeout := Timeout} = State) ->
|
||||||
case do_get_status(PoolName, Timeout) of
|
case do_get_status(InstId, Timeout) of
|
||||||
ok ->
|
ok ->
|
||||||
connected;
|
connected;
|
||||||
{error, still_connecting} ->
|
{error, still_connecting} ->
|
||||||
|
@ -527,12 +528,7 @@ do_get_status(PoolName, Timeout) ->
|
||||||
case ehttpc:health_check(Worker, Timeout) of
|
case ehttpc:health_check(Worker, Timeout) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
{error, Reason} = Error ->
|
{error, _} = Error ->
|
||||||
?SLOG(error, #{
|
|
||||||
msg => "http_connector_get_status_failed",
|
|
||||||
reason => redact(Reason),
|
|
||||||
worker => Worker
|
|
||||||
}),
|
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -543,14 +539,20 @@ do_get_status(PoolName, Timeout) ->
|
||||||
case [E || {error, _} = E <- Results] of
|
case [E || {error, _} = E <- Results] of
|
||||||
[] ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
Errors ->
|
[{error, Reason} | _] ->
|
||||||
hd(Errors)
|
?SLOG(info, #{
|
||||||
|
msg => "health_check_failed",
|
||||||
|
reason => redact(Reason),
|
||||||
|
connector => PoolName
|
||||||
|
}),
|
||||||
|
{error, Reason}
|
||||||
end
|
end
|
||||||
catch
|
catch
|
||||||
exit:timeout ->
|
exit:timeout ->
|
||||||
?SLOG(error, #{
|
?SLOG(info, #{
|
||||||
msg => "http_connector_pmap_failed",
|
msg => "health_check_failed",
|
||||||
reason => timeout
|
reason => timeout,
|
||||||
|
connector => PoolName
|
||||||
}),
|
}),
|
||||||
{error, timeout}
|
{error, timeout}
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in New Issue