|
|
|
@ -3,6 +3,7 @@ package service |
|
|
|
|
import ( |
|
|
|
|
"context" |
|
|
|
|
"encoding/json" |
|
|
|
|
"sync/atomic" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing" |
|
|
|
@ -27,7 +28,7 @@ type UsageStats struct { |
|
|
|
|
externalMetrics []usagestats.MetricsFunc |
|
|
|
|
sendReportCallbacks []usagestats.SendReportCallbackFunc |
|
|
|
|
|
|
|
|
|
readyToReport bool |
|
|
|
|
readyToReport atomic.Bool |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ProvideService(cfg *setting.Cfg, |
|
|
|
@ -79,7 +80,7 @@ func (uss *UsageStats) Run(ctx context.Context) error { |
|
|
|
|
for { |
|
|
|
|
select { |
|
|
|
|
case <-sendReportTicker.C: |
|
|
|
|
if !uss.readyToReport { |
|
|
|
|
if !uss.readyToReport.Load() { |
|
|
|
|
nextSendInterval = time.Minute |
|
|
|
|
sendReportTicker.Reset(nextSendInterval) |
|
|
|
|
continue |
|
|
|
@ -114,7 +115,7 @@ func (uss *UsageStats) RegisterSendReportCallback(c usagestats.SendReportCallbac |
|
|
|
|
|
|
|
|
|
func (uss *UsageStats) SetReadyToReport(context.Context) { |
|
|
|
|
uss.log.Info("Usage stats are ready to report") |
|
|
|
|
uss.readyToReport = true |
|
|
|
|
uss.readyToReport.Store(true) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (uss *UsageStats) supportBundleCollector() supportbundles.Collector { |
|
|
|
|