Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.36.0] - 2025-08-25

### Changed
- Add the `spring.id` tag to the kafka client metrics, for created kafka producers, to avoid warnings about registering meters with different tag keys
on Spring Boot 3.4+

## [0.35.0] - 2025-06-18

### Changed
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.35.0
version=0.36.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.transferwise.common.gracefulshutdown.GracefulShutdownStrategy;
import com.transferwise.kafka.tkms.api.TkmsShardPartition;
import com.transferwise.kafka.tkms.config.TkmsProperties.ShardProperties;
import io.micrometer.core.instrument.ImmutableTag;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.kafka.KafkaClientMetrics;
import java.time.Duration;
Expand Down Expand Up @@ -66,9 +67,10 @@ public Producer<String, byte[]> getKafkaProducer(TkmsShardPartition shardPartiti
configs.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, "5000");
configs.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, "5000");
configs.put(ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, "10000");
configs.put(ProducerConfig.CLIENT_ID_CONFIG,
"tw-tkms-" + shardPartition.getShard() + "-" + shardPartition.getPartition() + "-" + useCase.name().toLowerCase()
+ "-" + sequence.incrementAndGet());

final var clientId = "tw-tkms-" + shardPartition.getShard() + "-" + shardPartition.getPartition() + "-" + useCase.name().toLowerCase()
+ "-" + sequence.incrementAndGet();
configs.put(ProducerConfig.CLIENT_ID_CONFIG, clientId);

if (useCase == UseCase.PROXY) {
// We use large lingering time, because we are calling the `.flush()` anyway.
Expand All @@ -92,7 +94,9 @@ public Producer<String, byte[]> getKafkaProducer(TkmsShardPartition shardPartiti
}

final var producer = getKafkaProducer(configs);
final var kafkaClientMetrics = new KafkaClientMetrics(producer);
// Spring id is added to be compatible with Spring Boot Actuator's Kafka metrics, which from 3.4 onwards include the spring.id tag. Without
// warnings may be generated on service startup, about registering meters with different sets of tag keys
final var kafkaClientMetrics = new KafkaClientMetrics(producer, List.of(new ImmutableTag("spring.id", clientId)));
kafkaClientMetrics.bindTo(meterRegistry);

return new ProducerEntry().setProducer(producer).setKafkaClientMetric(kafkaClientMetrics);
Expand Down
Loading