From 69ac6b9e0dbeb8858019fd92dc33ed700b5e3cf4 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Mon, 2 Jan 2023 09:23:38 -0300 Subject: [PATCH] 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. --- .../src/kafka/emqx_bridge_impl_kafka_producer.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib-ee/emqx_ee_bridge/src/kafka/emqx_bridge_impl_kafka_producer.erl b/lib-ee/emqx_ee_bridge/src/kafka/emqx_bridge_impl_kafka_producer.erl index 94aff0714..ada443019 100644 --- a/lib-ee/emqx_ee_bridge/src/kafka/emqx_bridge_impl_kafka_producer.erl +++ b/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},