Merge pull request #12351 from HJianBo/improve-the-http-connector-logs

chore: improve http connector logs format
This commit is contained in:
JianBo He 2024-01-22 10:27:35 +08:00 committed by GitHub
commit f7ae9ab489
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 13 deletions

View File

@ -252,6 +252,7 @@ start_pool(PoolName, PoolOpts) ->
{error, {already_started, _}} ->
?SLOG(warning, #{
msg => "emqx_connector_on_start_already_started",
connector => PoolName,
pool_name => PoolName
}),
ok;
@ -510,8 +511,8 @@ resolve_pool_worker(#{pool_name := PoolName} = State, Key) ->
on_get_channels(ResId) ->
emqx_bridge_v2:get_channels_for_connector(ResId).
on_get_status(_InstId, #{pool_name := PoolName, connect_timeout := Timeout} = State) ->
case do_get_status(PoolName, Timeout) of
on_get_status(InstId, #{pool_name := InstId, connect_timeout := Timeout} = State) ->
case do_get_status(InstId, Timeout) of
ok ->
connected;
{error, still_connecting} ->
@ -527,12 +528,7 @@ do_get_status(PoolName, Timeout) ->
case ehttpc:health_check(Worker, Timeout) of
ok ->
ok;
{error, Reason} = Error ->
?SLOG(error, #{
msg => "http_connector_get_status_failed",
reason => redact(Reason),
worker => Worker
}),
{error, _} = Error ->
Error
end
end,
@ -543,14 +539,20 @@ do_get_status(PoolName, Timeout) ->
case [E || {error, _} = E <- Results] of
[] ->
ok;
Errors ->
hd(Errors)
[{error, Reason} | _] ->
?SLOG(info, #{
msg => "health_check_failed",
reason => redact(Reason),
connector => PoolName
}),
{error, Reason}
end
catch
exit:timeout ->
?SLOG(error, #{
msg => "http_connector_pmap_failed",
reason => timeout
?SLOG(info, #{
msg => "health_check_failed",
reason => timeout,
connector => PoolName
}),
{error, timeout}
end.