According to the influxdb-java manual, it's a recommended approach to write data using its built-in batching functionality (and it's showcased as the first example). However I'm not sure where should I call influxDB.enableBatch and influxDB.close when using it in Spring Boot, or whether I should simply not use the auto-configured instance in that way.

I think it's pretty basic thus would better be included in the manual (the InfluxDB section is too simple compared to other parts of the manual currently). Sorry if this should be a StackOverflow question instead.

Furthermore, maybe the auto-configuration itself could be improved by enabling users to specify whether to use batching, the default database and retention policy in the application properties?

Comment From: wilkinsona

However I'm not sure where should I call … influxDB.close

The InfluxDB instance is exposed as bean via a @Bean method. As noted in Spring Framework's reference documentation this means that its public close() method will be called automatically when the application context is closed:

By default, beans defined with Java configuration that have a public close or shutdown method are automatically enlisted with a destruction callback.

or whether I should simply not use the auto-configured instance in that way.

As with any other auto-configured bean, it depends on whether or not it meets your needs and how the bean behaves when you reconfigure it. The contract of InfluxDB looks as if it supports reconfiguring an instance but this has to be done with some care. For example, an exception will be thrown if you attempt to enable batching twice. You are probably best configuring an InfluxDB bean yourself. This will cause the auto-configured one to back off.

Furthermore, maybe the auto-configuration itself could be improved by enabling users to specify whether to use batching, the default database and retention policy in the application properties?

I think it's worth looking at adding some configuration properties to configure the settings encapsulated by org.influxdb.BatchOptions. However the exception handler and thread factory would always need to be configured in code as their types aren't suitable for property-based configuration.

Comment From: eddumelendez

At the beginning I think that having a property spring.influx.batch.enabled would help to enable default values. But also an InfluxDBCustomizer can help to do so and to set and custom BatchOptions if it is needed.

Comment From: snicoll

I am torn. I can certainly see how the customizer could be helpful but since you can't enableBatch twice, exposing a property can be problematic. You can check if batching is enabled and even disable it (to enable it again with different options?).

Anyways, as a recent InfluxDB user myself, I can see this auto-configuration could use some more love :)

Comment From: eddumelendez

@snicoll I was planning to contribute with this one but saw is assigned to you. So, I think you will be working on this, right? If so, that's fine just want to make sure and of course hope to see the auto-configuration love you were talking about :)

Comment From: snicoll

Thanks for asking @eddumelendez. If you want to contribute something, please go ahead and I'd love reviewing your proposal. One thing though, exposing only the boolean flag may not give enough control so I'd like us to explore exposing a few more properties so that users don't have to go the customizer routes only they really need to.

Comment From: scottfrederick

Closing in favor of #25319