Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Boot starter: auto-configure Kafka metrics reporter #12905

Open
drazzib opened this issue Dec 17, 2024 · 5 comments
Open

Spring Boot starter: auto-configure Kafka metrics reporter #12905

drazzib opened this issue Dec 17, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@drazzib
Copy link

drazzib commented Dec 17, 2024

Is your feature request related to a problem? Please describe.

I'm not sure if the current behavior is desired or if it's an oversight
(I'll let you reclassify this as a bug at your convenience).

On a Spring Boot service, we have just migrated from instrumentation via the OpenTelemetry JVM agent to using the Spring Boot Starter JAR as dependency. Unfortunately, with Spring Boot Starter auto-configuration, we no longer have Kafka metrics associated with our consumer or producer.

The metrics we used to depends on are described in this page: Library instrumentation for Kafka Clients#Usage (Metrics).

Describe the solution you'd like

If I understood correctly, the Kafka metrics are activated via KafkaMetricsUtil#enhanceConfig in the following javaagent instrumentations:

It seems relevant - to me at least :) - to have something similar in the Spring Boot Starter module (perhaps enable/disable via a configuration property)

Describe alternatives you've considered

I don't see a way to add the properties (to enable OpenTelemetryMetricsReporter ) in Spring Kafka consumers or producers in the auto-configuration mechanisms (either KafkaInstrumentationAutoConfiguration or ConcurrentKafkaListenerContainerFactoryPostProcessor)

Additional context

Current behavior tested with:

Spring Boot: 3.3.6 / OpenTelemetry Spring Boot Starter: v2.7.0

@drazzib drazzib added enhancement New feature or request needs triage New issue that requires triage labels Dec 17, 2024
@steverao
Copy link
Contributor

cc @zeitlinger @jeanbisutti

@steverao steverao removed the needs triage New issue that requires triage label Dec 17, 2024
@zeitlinger
Copy link
Member

The spring starter can only use library instrumentations.

Kafka currently only has agent based instrumentation. I'm not sure if it can be done. If yes, a PR would be welcome.

@trask
Copy link
Member

trask commented Dec 17, 2024

@zeitlinger
Copy link
Member

Thx - missed that.

So the starter uses the spring library instrumentation, which doesn't support metrics - and spring doesn't seem to allow access to the underlying hooks.
Micrometer seems to create metrics from the operation interceptors - which we could also do here:

https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/kafka/KafkaInstrumentationAutoConfiguration.java

@laurit
Copy link
Contributor

laurit commented Dec 18, 2024

I don't see a way to add the properties (to enable OpenTelemetryMetricsReporter ) in Spring Kafka consumers or producers in the auto-configuration mechanisms (either KafkaInstrumentationAutoConfiguration or ConcurrentKafkaListenerContainerFactoryPostProcessor)

I'd try DefaultKafkaConsumerFactoryCustomizer and DefaultKafkaProducerFactoryCustomizer updateConfigs should let you update the configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants