Produce()
from kafka.Producer
will always return no errors if cfg.Sync=true
#513
Labels
bug
Something isn't working
Produce()
method ofkafka.Producer
has this signature:apm-queue/kafka/producer.go
Line 210 in a508dbd
It also has 2 behaviors: async and sync production. This behavior is triggered by the
cfg.Sync
config option.In the async production case the errors occurring are passed over to the
cfg.ProduceCallback
if specified. This is correct.In the sync production case errors occurring are not collected in any way and will never be returned to the caller. Worse: the caller will never know an error happened.
This is the relevant code where we produce to kafka:
apm-queue/kafka/producer.go
Lines 243 to 258 in a508dbd
I'm not sure this behavior is intended and I would consider it a bug. The solution could be to collect errors with
errors.Join
and return the resulting error on line 261apm-queue/kafka/producer.go
Lines 260 to 264 in a508dbd
This way on
cfg.Sync=true
errors would be collected and returned. Oncfg.Sync=false
the code would not wait thus returningnil
keeping the current behavior.The text was updated successfully, but these errors were encountered: