Skip to content

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

Merged
trask merged 21 commits intoopen-telemetry:mainfrom
onurkybsi:kafka-bootstrap-servers
Apr 17, 2026
Merged

messaging.kafka.bootstrap.servers added for KafkaProducer#17065
trask merged 21 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @laurit, thanks for the review, it's done!

@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch 2 times, most recently from f8727e0 to 6514ffb Compare April 6, 2026 13:44
@trask
Copy link
Copy Markdown
Member

trask commented Apr 8, 2026

hey @onurkybsi! don't be alarmed, I just pushed 8d1a604 to your branch to align with some repo test conventions and bring the diff line count down a bit in the process

@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch 2 times, most recently from 752f542 to 02aef9f Compare April 14, 2026 17:45
onurkybsi and others added 16 commits April 14, 2026 20:34
# 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

# Conflicts:
#	instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/internal/KafkaProducerTelemetry.java
@onurkybsi onurkybsi force-pushed the kafka-bootstrap-servers branch from 327fa0b to 4c2d083 Compare April 14, 2026 18:34
implements AttributesExtractor<KafkaProducerRequest, RecordMetadata> {

private static final AttributeKey<String> MESSAGING_KAFKA_BOOTSTRAP_SERVERS =
AttributeKey.stringKey("messaging.kafka.bootstrap.servers");
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.

wondering whether stringArrayKey would be a better fit as we really have a list of bootstrap servers
@trask do you have any guidance on this

@laurit laurit added this to the v2.27.0 milestone Apr 16, 2026
equalTo(MESSAGING_KAFKA_MESSAGE_OFFSET, 0),
equalTo(
stringKey("messaging.kafka.bootstrap.servers"),
isExperimental ? kafka.getBootstrapServers() : null));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @laurit, fyi, I was getting warning since equalTo parameters are not nullable, that's why I had made my change.

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.

nobody has gotten around to submitting a PR that adds the @Nullable annotation there

@trask trask enabled auto-merge (squash) April 17, 2026 01:45
@trask trask disabled auto-merge April 17, 2026 02:44
…vers

# Conflicts:
#	instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/InterceptorsTest.java
#	instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/WrapperSuppressReceiveSpansTest.java
#	instrumentation/kafka/kafka-clients/kafka-clients-2.6/library/src/test/java/io/opentelemetry/instrumentation/kafkaclients/v2_6/WrapperTest.java
@trask trask enabled auto-merge (squash) April 17, 2026 03:26
@trask trask merged commit 3782234 into open-telemetry:main Apr 17, 2026
93 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Apr 17, 2026

Thank you for your contribution @onurkybsi! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

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.

3 participants