You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug description
When a meter registry customization is registered and the management.metrics.use-global-registry property is disabled, some spring-batch metrics are being registered in the meter registry customization and others in the meter registry global.
Metrics registered in meter registry customization
spring.batch.job
spring.batch.job.active
spring.batch.step
spring.batch.step.active
Metrics registered in the global meter registry
spring.batch.item.read
spring.batch.item.process
spring.batch.chunk.write
Environment
Please provide as many details as possible: Spring Batch version, Java version, which database you use if any, etc
Spring Batch version: 5.2.1
java version:
openjdk 21.0.3 2024-04-16 LTS
OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode, sharing)
Steps to reproduce
Create a SimpleMeterRegistry
management.metrics.use-global-registry=false
Define job with step and reader, processor and writer
Check metrics in the custom SimpleMeterRegistry
Expected behavior
Metrics spring.batch.item.read, spring.batch.item.process and spring.batch.chunk.write are registered the custom registry meter
Thank you for reporting this issue. Spring Batch reports metrics to Micrometer's global registry (there is a note about it here), so I am not sure disabling management.metrics.use-global-registry is compatible with Spring Batch.
But I believe the issue is not related to that. The issue is that by default, the global registry of Micrometer is an empty composite. So if you want to use a custom registry, you need to add it to the global one prior to running your job. For instance, you test passes if I add the registry like follows:
I remember this was confusing to other users as well (see https://stackoverflow.com/questions/64869472/spring-batch-and-boot-micrometer), so I think we need to make this clearer in the reference documentation. BTW, we have a sample that uses prometheus for metrics, and it shows how the registry is added to the global composite beforehand.
Bug description
When a meter registry customization is registered and the management.metrics.use-global-registry property is disabled, some spring-batch metrics are being registered in the meter registry customization and others in the meter registry global.
Metrics registered in meter registry customization
Metrics registered in the global meter registry
Environment
Please provide as many details as possible: Spring Batch version, Java version, which database you use if any, etc
Steps to reproduce
Expected behavior
Metrics
spring.batch.item.read
,spring.batch.item.process
andspring.batch.chunk.write
are registered the custom registry meterMinimal Complete Reproducible example
Complete sample: sb-batch.zip
Related issue
The text was updated successfully, but these errors were encountered: