fix: increment dropped message counter when bridge is unhealthy
Fixes https://emqx.atlassian.net/browse/EMQX-10767
This commit is contained in:
parent
2c89be04d1
commit
cc3ba18734
|
@ -281,8 +281,10 @@ query(ResId, Request, Opts) ->
|
||||||
{ok, _Group, #{query_mode := QM, error := Error}} ->
|
{ok, _Group, #{query_mode := QM, error := Error}} ->
|
||||||
case {QM, Error} of
|
case {QM, Error} of
|
||||||
{_, unhealthy_target} ->
|
{_, unhealthy_target} ->
|
||||||
|
emqx_resource_metrics:dropped_resource_stopped_inc(ResId),
|
||||||
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
||||||
{_, {unhealthy_target, _Message}} ->
|
{_, {unhealthy_target, _Message}} ->
|
||||||
|
emqx_resource_metrics:dropped_resource_stopped_inc(ResId),
|
||||||
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
?RESOURCE_ERROR(unhealthy_target, "unhealthy target");
|
||||||
{simple_async, _} ->
|
{simple_async, _} ->
|
||||||
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
%% TODO(5.1.1): pass Resource instead of ResId to simple APIs
|
||||||
|
|
|
@ -899,6 +899,29 @@ t_healthy(_) ->
|
||||||
end
|
end
|
||||||
).
|
).
|
||||||
|
|
||||||
|
t_unhealthy_target(_) ->
|
||||||
|
HealthCheckError = {unhealthy_target, "some message"},
|
||||||
|
?assertMatch(
|
||||||
|
{ok, _},
|
||||||
|
emqx_resource:create_local(
|
||||||
|
?ID,
|
||||||
|
?DEFAULT_RESOURCE_GROUP,
|
||||||
|
?TEST_RESOURCE,
|
||||||
|
#{name => test_resource, health_check_error => {msg, HealthCheckError}}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
?assertEqual(
|
||||||
|
{ok, disconnected},
|
||||||
|
emqx_resource:health_check(?ID)
|
||||||
|
),
|
||||||
|
?assertMatch(
|
||||||
|
{ok, _Group, #{error := HealthCheckError}},
|
||||||
|
emqx_resource_manager:lookup(?ID)
|
||||||
|
),
|
||||||
|
%% messages are dropped when bridge is unhealthy
|
||||||
|
emqx_resource:query(?ID, message),
|
||||||
|
?assertEqual(1, emqx_resource_metrics:dropped_resource_stopped_get(?ID)).
|
||||||
|
|
||||||
t_stop_start(_) ->
|
t_stop_start(_) ->
|
||||||
?check_trace(
|
?check_trace(
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed increment on data bridge statistics when bridge is unhealthy. Now, messages sent to unhealthy bridges are being counted as dropped messages.
|
Loading…
Reference in New Issue