elastic/apm-queue

kafka: TopicCreator.CreateTopics performs unnecessary topic updates

Opened this issue · 0 comments

axw commented

if len(existingTopics) > 0 && len(c.topicConfigs) > 0 {
alterCfg := make([]kadm.AlterConfig, 0, len(c.topicConfigs))
for k, v := range c.topicConfigs {
alterCfg = append(alterCfg, kadm.AlterConfig{Name: k, Value: v})
}
alterResp, err := c.m.adminClient.AlterTopicConfigs(ctx,
alterCfg, existingTopics...,
)

As soon as a topic has been created, this code will always trigger an AlterTopicConfigs if there are any topic configs defined. This creates unnecessary API calls to Kafka, and creates log spam.