Skip to content

messaging.kafka.bootstrap.servers added for KafkaProducer#17065

Open
onurkybsi wants to merge 6 commits intoopen-telemetry:mainfrom
onurkybsi:kafka-bootstrap-servers
Open

messaging.kafka.bootstrap.servers added for KafkaProducer#17065
onurkybsi wants to merge 6 commits intoopen-telemetry:mainfrom
onurkybsi:kafka-bootstrap-servers

Conversation

@onurkybsi
Copy link
Copy Markdown
Contributor

messaging.kafka.bootstrap.servers attribute added for instrumented KafkaProducer, see #10647.

@onurkybsi onurkybsi marked this pull request as ready for review March 25, 2026 19:17
@onurkybsi onurkybsi requested a review from a team as a code owner March 25, 2026 19:17
@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch from 6484a3b to d125e22 Compare March 27, 2026 18:00
Comment on lines +41 to +42
if (request.getBootstrapServers() != null) {
attributes.put(MESSAGING_KAFKA_BOOTSTRAP_SERVERS, request.getBootstrapServers());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/** Sets Kafka consumer configurations. */
@CanIgnoreReturnValue
public KafkaTelemetryBuilder setProducerConfigs(Map<String, Object> producerConfigs) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not ideal, currently the same KafkaTelemetry instance could be used to add telemetry to different producers but with this it is not the case any more. Did you consider alternatives like using reflection to read the producerConfig field in KafkaProducer?

@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch from c13074b to f8727e0 Compare April 2, 2026 19:35
# Conflicts:
#	instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/KafkaTelemetryBuilder.java

# Conflicts:
#	instrumentation/spring/spring-kafka-2.7/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/kafka/v2_7/SpringKafkaTest.java
@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch from f8727e0 to 6514ffb Compare April 6, 2026 13:44
val -> val.isInstanceOf(String.class)),
equalTo(MESSAGING_KAFKA_MESSAGE_OFFSET, 0),
equalTo(MESSAGING_KAFKA_MESSAGE_KEY, "10")));
if (isExperimental) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could instead use

                      satisfies(
                          MESSAGING_KAFKA_BOOTSTRAP_SERVERS,
                          stringAssert -> {
                              if (isExperimental) {
                                stringAssert.matches("^localhost:\\d+(,localhost:\\d+)*$");
                              }
                          }));

then you wouldn't need the assertions list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants