MCPcopy Index your code
hub / github.com/coder/coder / runSnapshotter

Method runSnapshotter

coderd/telemetry/telemetry.go:250–284  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248}
249
250func (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
286func (r *remoteReporter) reportWithDeployment() {
287 // Submit deployment information before creating a snapshot!

Callers 1

NewFunction · 0.95

Calls 9

EnabledMethod · 0.95
reportSyncMethod · 0.95
isClosedMethod · 0.95
reportWithDeploymentMethod · 0.95
RecordTelemetryStatusFunction · 0.85
StopMethod · 0.65
ErrorMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected