()
| 248 | } |
| 249 | |
| 250 | func (r *remoteReporter) runSnapshotter() { |
| 251 | telemetryDisabledSnapshot, err := RecordTelemetryStatus(r.ctx, r.options.Logger, r.options.Database, r.Enabled()) |
| 252 | if err != nil { |
| 253 | r.options.Logger.Debug(r.ctx, "record and maybe report telemetry status", slog.Error(err)) |
| 254 | } |
| 255 | if telemetryDisabledSnapshot != nil { |
| 256 | r.reportSync(telemetryDisabledSnapshot) |
| 257 | } |
| 258 | r.options.Logger.Debug(r.ctx, "finished telemetry status check") |
| 259 | if !r.Enabled() { |
| 260 | return |
| 261 | } |
| 262 | |
| 263 | first := true |
| 264 | ticker := time.NewTicker(r.options.SnapshotFrequency) |
| 265 | defer ticker.Stop() |
| 266 | for { |
| 267 | if !first { |
| 268 | select { |
| 269 | case <-r.closed: |
| 270 | return |
| 271 | case <-ticker.C: |
| 272 | } |
| 273 | // Skip the ticker on the first run to report instantly! |
| 274 | } |
| 275 | first = false |
| 276 | r.closeMutex.Lock() |
| 277 | if r.isClosed() { |
| 278 | r.closeMutex.Unlock() |
| 279 | return |
| 280 | } |
| 281 | r.reportWithDeployment() |
| 282 | r.closeMutex.Unlock() |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | func (r *remoteReporter) reportWithDeployment() { |
| 287 | // Submit deployment information before creating a snapshot! |
no test coverage detected