Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

relay: fix bug of relay metrics being recorded only once (#1748) #1753

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions relay/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,18 @@ func reportRelayLogSpaceInBackground(ctx context.Context, dirpath string) error
ticker = time.NewTicker(time.Duration(t) * time.Second)
})
defer ticker.Stop()
select {
case <-ctx.Done():
return
case <-ticker.C:
size, err := utils.GetStorageSize(dirpath)
if err != nil {
log.L().Error("fail to update relay log storage size", log.ShortError(err))
} else {
relayLogSpaceGauge.WithLabelValues("capacity").Set(float64(size.Capacity))
relayLogSpaceGauge.WithLabelValues("available").Set(float64(size.Available))
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
size, err := utils.GetStorageSize(dirpath)
if err != nil {
log.L().Error("fail to update relay log storage size", log.ShortError(err))
} else {
relayLogSpaceGauge.WithLabelValues("capacity").Set(float64(size.Capacity))
relayLogSpaceGauge.WithLabelValues("available").Set(float64(size.Available))
}
}
}
}()
Expand Down