Skip to content

Commit

Permalink
fix: kafka send stat (#871)
Browse files Browse the repository at this point in the history
Co-authored-by: saimu.msm <saimu.msm@antfin.com>
  • Loading branch information
masaimu and saimu.msm authored Jul 1, 2024
1 parent 2d64ab8 commit 18199ce
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.errors.RecordTooLargeException;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;

Expand Down Expand Up @@ -314,7 +315,12 @@ private boolean send(AggTaskKey key, AggProtos.AggTaskValue value) {
if (value.hasDataTable()) {
count += value.getDataTable().getRowCount();
}
if (exception != null) {
if (exception instanceof RecordTooLargeException) {
log.warn("[agg] [{}] write kafka error for {}, metric=[{}] size=[{}]", //
key, exception.getMessage(), value.getMetric(), count);
StatUtils.KAFKA_SEND.add(StringsKey.of(topic, "DISCARD", "unknownPartition"),
new long[] {1, count, 0});
} else if (exception != null) {
log.error("[agg] [{}] write kafka error, metric=[{}] size=[{}]", //
key, value.getMetric(), count, exception);
StatUtils.KAFKA_SEND.add(StringsKey.of(topic, "ERROR", "unknownPartition"),
Expand Down

0 comments on commit 18199ce

Please sign in to comment.