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

Struct UsageTracker

coderd/workspacestats/tracker.go:30–42  ·  view source on GitHub ↗

UsageTracker tracks and de-bounces updates to workspace usage activity. It keeps an internal map of workspace IDs that have been used and periodically flushes this to its configured Store.

Source from the content-addressed store, hash-verified

28// It keeps an internal map of workspace IDs that have been used and
29// periodically flushes this to its configured Store.
30type UsageTracker struct {
31 log slog.Logger // you know, for logs
32 flushLock sync.Mutex // protects m
33 flushErrors int // tracks the number of consecutive errors flushing
34 m *uuidSet // stores workspace ids
35 s Store // for flushing data
36 tickCh <-chan time.Time // controls flush interval
37 stopTick func() // stops flushing
38 stopCh chan struct{} // signals us to stop
39 stopOnce sync.Once // because you only stop once
40 doneCh chan struct{} // signifies that we have stopped
41 flushCh chan int // used for testing.
42}
43
44// NewTracker returns a new Tracker. It is the caller's responsibility
45// to call Close().

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected