ruby-kafka
ruby-kafka copied to clipboard
Extra space in `[Producer ]` prefix of async producer logs
If this is a bug report, please fill out the following:
- Version of Ruby: 3.1.0
- Version of Kafka: 1.1.1
- Version of ruby-kafka: 1.4.0
Please verify that the problem you're seeing hasn't been fixed by the current master
of ruby-kafka.
Steps to reproduce
require 'logger'
require 'kafka'
kafka = Kafka.new('broker', logger: Logger.new($stdout))
producer = kafka.async_producer
producer.produce('{}', topic: 'foo')
# I, [2022-03-28T09:58:47.029059 #16575] INFO -- : [Producer ] Starting async producer in the background...
producer.deliver_messages
# I, [2022-03-28T09:59:05.392330 #16575] INFO -- : [Producer ] New topics added to target list: foo
# I, [2022-03-28T09:59:05.393114 #16575] INFO -- : [Producer ] Fetching cluster metadata from kafka://broker:9092
Expected outcome
I would expect to see [Producer]
(without the space after r
), or [Producer foo]
once I see New topics added to target list: foo
message.
Actual outcome
[Producer ]
I looked at the code and it seems that the trailing space was not intended.
https://github.com/zendesk/ruby-kafka/blob/d5def61ad82ca6ed2645939c202ec967208d7787/lib/kafka/async_producer.rb#L212
https://github.com/zendesk/ruby-kafka/blob/d5def61ad82ca6ed2645939c202ec967208d7787/lib/kafka/producer.rb#L160-L162
(@target_topics
is empty when push_tags
is called.)
Suggestion
- Add
chomp
orstrip
toProducer#to_s
- Or if it's possible, update the prefix when
@target_topics
of sync producer is updated. (proc tag?)