Merge pull request #13414 from kjellwinblad/kjell/review_connector_error_logs_rabbitmq_etc/EMQX-12462
fix: make RabbitMQ error log messages easier to understand
This commit is contained in:
commit
c8258cebe8
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_bridge_rabbitmq, [
|
{application, emqx_bridge_rabbitmq, [
|
||||||
{description, "EMQX Enterprise RabbitMQ Bridge"},
|
{description, "EMQX Enterprise RabbitMQ Bridge"},
|
||||||
{vsn, "0.2.1"},
|
{vsn, "0.2.2"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{mod, {emqx_bridge_rabbitmq_app, []}},
|
{mod, {emqx_bridge_rabbitmq_app, []}},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|
|
@ -279,8 +279,31 @@ publish_messages(
|
||||||
{error, Reason};
|
{error, Reason};
|
||||||
%% if send a message to a non-existent exchange, RabbitMQ client will crash
|
%% if send a message to a non-existent exchange, RabbitMQ client will crash
|
||||||
%% {shutdown,{server_initiated_close,404,<<"NOT_FOUND - no exchange 'xyz' in vhost '/'">>}
|
%% {shutdown,{server_initiated_close,404,<<"NOT_FOUND - no exchange 'xyz' in vhost '/'">>}
|
||||||
%% so we catch and return {recoverable_error, Reason} to increase metrics
|
%% so we catch and return a more user friendly message in that case.
|
||||||
|
%% This seems to happen sometimes when the exchange does not exists.
|
||||||
|
exit:{{shutdown, {server_initiated_close, Code, Msg}}, _InternalReason} ->
|
||||||
|
?tp(emqx_bridge_rabbitmq_connector_rabbit_publish_failed_with_msg, #{}),
|
||||||
|
{error,
|
||||||
|
{recoverable_error, #{
|
||||||
|
msg => <<"rabbitmq_publish_failed">>,
|
||||||
|
explain => Msg,
|
||||||
|
exchange => Exchange,
|
||||||
|
routing_key => RoutingKey,
|
||||||
|
rabbit_mq_error_code => Code
|
||||||
|
}}};
|
||||||
|
%% This probably happens when the RabbitMQ driver is restarting the connection process
|
||||||
|
exit:{noproc, _} = InternalError ->
|
||||||
|
?tp(emqx_bridge_rabbitmq_connector_rabbit_publish_failed_con_not_ready, #{}),
|
||||||
|
{error,
|
||||||
|
{recoverable_error, #{
|
||||||
|
msg => <<"rabbitmq_publish_failed">>,
|
||||||
|
explain => "Connection is establishing",
|
||||||
|
exchange => Exchange,
|
||||||
|
routing_key => RoutingKey,
|
||||||
|
internal_error => InternalError
|
||||||
|
}}};
|
||||||
_Type:Reason ->
|
_Type:Reason ->
|
||||||
|
?tp(emqx_bridge_rabbitmq_connector_rabbit_publish_failed_other, #{}),
|
||||||
Msg = iolist_to_binary(io_lib:format("RabbitMQ: publish_failed: ~p", [Reason])),
|
Msg = iolist_to_binary(io_lib:format("RabbitMQ: publish_failed: ~p", [Reason])),
|
||||||
{error, {recoverable_error, Msg}}
|
{error, {recoverable_error, Msg}}
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -288,7 +288,9 @@ t_action_not_exist_exchange(_Config) ->
|
||||||
description => <<"bridge_v2 send msg to rabbitmq action failed">>
|
description => <<"bridge_v2 send msg to rabbitmq action failed">>
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
ok = snabbkaffe:start_trace(),
|
||||||
on_exit(fun() ->
|
on_exit(fun() ->
|
||||||
|
snabbkaffe:stop(),
|
||||||
emqx_rule_engine:delete_rule(RuleId),
|
emqx_rule_engine:delete_rule(RuleId),
|
||||||
_ = delete_action(Name)
|
_ = delete_action(Name)
|
||||||
end),
|
end),
|
||||||
|
@ -316,6 +318,25 @@ t_action_not_exist_exchange(_Config) ->
|
||||||
ok = delete_action(Name),
|
ok = delete_action(Name),
|
||||||
ActionsAfterDelete = emqx_bridge_v2:list(actions),
|
ActionsAfterDelete = emqx_bridge_v2:list(actions),
|
||||||
?assertNot(lists:any(Any, ActionsAfterDelete), ActionsAfterDelete),
|
?assertNot(lists:any(Any, ActionsAfterDelete), ActionsAfterDelete),
|
||||||
|
Trace = snabbkaffe:collect_trace(50),
|
||||||
|
?assert(
|
||||||
|
lists:any(
|
||||||
|
fun(K) ->
|
||||||
|
maps:get(msg, K, not_found) =:=
|
||||||
|
emqx_bridge_rabbitmq_connector_rabbit_publish_failed_with_msg
|
||||||
|
end,
|
||||||
|
Trace
|
||||||
|
)
|
||||||
|
),
|
||||||
|
?assert(
|
||||||
|
lists:any(
|
||||||
|
fun(K) ->
|
||||||
|
maps:get(msg, K, not_found) =:=
|
||||||
|
emqx_bridge_rabbitmq_connector_rabbit_publish_failed_con_not_ready
|
||||||
|
end,
|
||||||
|
Trace
|
||||||
|
)
|
||||||
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_replace_action_source(Config) ->
|
t_replace_action_source(Config) ->
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The RabbitMQ error log messages have been improved to provide clearer and more detailed information.
|
Loading…
Reference in New Issue