Update opentsdb.go

This commit is contained in:
anim001k 2025-10-03 10:02:21 +02:00 committed by GitHub
parent 1e4b39ed12
commit b96bece193
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,7 +39,9 @@ func OpenTSDB(r Registry, d time.Duration, prefix string, addr *net.TCPAddr) {
// OpenTSDBWithConfig is a blocking exporter function just like OpenTSDB,
// but it takes a OpenTSDBConfig instead.
func OpenTSDBWithConfig(c OpenTSDBConfig) {
for range time.Tick(c.FlushInterval) {
ticker := time.NewTicker(c.FlushInterval)
defer ticker.Stop() // Use NewTicker to allow explicit stop and avoid leaked timers.
for range ticker.C {
if err := openTSDB(&c); nil != err {
log.Println(err)
}