Skip to content

Commit 3fc604d

Browse files
committed
Add messagingReceiveInstrumentationEnabled configuration to Kafka autoconfigure
The Kafka instrumentation autoconfiguration was missing the ability to configure messagingReceiveInstrumentationEnabled from the property 'otel.instrumentation.messaging.experimental.receive-telemetry.enabled'. This is required to control creation of separate spans in Spring Boot autoconfiguration for Kafka consumers. Changes: - Added setMessagingReceiveInstrumentationEnabled() call in KafkaInstrumentationAutoConfiguration - Uses the standard property 'otel.instrumentation.messaging.experimental.receive-telemetry.enabled' - Follows the same pattern as other messaging instrumentations (JMS, Pulsar, etc.) Fixes the missing configuration that was preventing proper control of Kafka consumer span creation in Spring Boot applications.
1 parent 63cf3ef commit 3fc604d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/kafka/KafkaInstrumentationAutoConfiguration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ DefaultKafkaProducerFactoryCustomizer otelKafkaProducerFactoryCustomizer(
4343
static SpringKafkaTelemetry getTelemetry(
4444
ObjectProvider<OpenTelemetry> openTelemetryProvider,
4545
ObjectProvider<InstrumentationConfig> configProvider) {
46+
InstrumentationConfig config = configProvider.getObject();
4647
return SpringKafkaTelemetry.builder(openTelemetryProvider.getObject())
4748
.setCaptureExperimentalSpanAttributes(
48-
configProvider
49-
.getObject()
50-
.getBoolean("otel.instrumentation.kafka.experimental-span-attributes", false))
49+
config.getBoolean("otel.instrumentation.kafka.experimental-span-attributes", false))
50+
.setMessagingReceiveInstrumentationEnabled(
51+
config.getBoolean("otel.instrumentation.messaging.experimental.receive-telemetry.enabled", false))
5152
.build();
5253
}
5354

0 commit comments

Comments
 (0)