Przeglądaj źródła

fix(kafka): fix handling of `dropped.queue_full` event from wolff

https://emqx.atlassian.net/browse/EMQX-8530

https://github.com/kafka4beam/wolff/blob/cd20a37e658f4ae3d1468ca20e7d302822ee85dd/src/wolff_producer.erl#L772-L773

Wolff emits 2 events related to dropped messages when replayq reports
overflow.  Since in EMQX's side we also bump `dropped` when
`dropped_queue_full` happens, that was leading to wrong metrics.
Thales Macedo Garitezi 3 lat temu
rodzic
commit
69ac6b9e0d

+ 8 - 1
lib-ee/emqx_ee_bridge/src/kafka/emqx_bridge_impl_kafka_producer.erl

@@ -318,7 +318,14 @@ handle_telemetry_event(
     #{bridge_id := ID},
     #{bridge_id := ID}
 ) when is_integer(Val) ->
-    emqx_resource_metrics:dropped_queue_full_inc(ID, Val);
+    %% When wolff emits a `dropped_queue_full' event due to replayq
+    %% overflow, it also emits a `dropped' event (at the time of
+    %% writing, wolff is 1.7.4).  Since we already bump `dropped' when
+    %% `dropped.queue_full' occurs, we have to correct it here.  This
+    %% correction will have to be dropped if wolff stops also emitting
+    %% `dropped'.
+    emqx_resource_metrics:dropped_queue_full_inc(ID, Val),
+    emqx_resource_metrics:dropped_inc(ID, -Val);
 handle_telemetry_event(
     [wolff, queuing],
     #{gauge_set := Val},