The auto-configured PrometheusPushGatewayManager created by PrometheusPushGatewayConfiguration is using the PushGatewayTaskScheduler. The PushGatewayTaskScheduler is a ThreadPoolTaskScheduler configured with 1 thread.
This scheduler is used to call org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager#post in a scheduled interval. This in turn calls io.prometheus.client.exporter.PushGateway#pushAdd(io.prometheus.client.CollectorRegistry, java.lang.String, java.util.Map<java.lang.String,java.lang.String>) which sends data to the push gateway. It doesn't contain any synchronized.
This could be refactored to use virtual threads.
Comment From: mhalbritter
We decided to not switch that to a virtual thread for now, but our mind can change in the future and based on feedback :)
If users want to use virtual threads for the PrometheusPushGatewayManager, they can create their own PrometheusPushGatewayManager bean with a SimpleAsyncTaskScheduler with virtual threads enabled.
Comment From: mhalbritter
If we decide to provide virtual threads out of the box, the changes are here: https://github.com/mhalbritter/spring-boot/tree/mh/36806-use-virtual-threads-in-pushgatewaytaskscheduler-if-enabled
There's a test, PrometheusPushGatewayManagerIntegrationTests which tests if the PrometheusPushGatewayManager pins a virtual thread while doing its work. This VirtualThreadPinningAssert could come in handy for other situations.