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

Method reportLocked

agent/stats.go:114–133  ·  view source on GitHub ↗
(
	ctx context.Context, dest statsDest, networkStats map[netlogtype.Connection]netlogtype.Counts,
)

Source from the content-addressed store, hash-verified

112}
113
114func (s *statsReporter) reportLocked(
115 ctx context.Context, dest statsDest, networkStats map[netlogtype.Connection]netlogtype.Counts,
116) error {
117 // here we want to do our collecting/reporting while it is unlocked, but then relock
118 // when we return to reportLoop.
119 s.L.Unlock()
120 defer s.L.Lock()
121 stats := s.collector.Collect(ctx, networkStats)
122 resp, err := dest.UpdateStats(ctx, &proto.UpdateStatsRequest{Stats: stats})
123 if err != nil {
124 return err
125 }
126 interval := resp.GetReportInterval().AsDuration()
127 if interval != s.lastInterval {
128 s.logger.Info(ctx, "new stats report interval", slog.F("interval", interval))
129 s.lastInterval = interval
130 s.source.SetConnStatsCallback(s.lastInterval, maxConns, s.callback)
131 }
132 return nil
133}

Callers 1

reportLoopMethod · 0.95

Calls 7

GetReportIntervalMethod · 0.80
CollectMethod · 0.65
UpdateStatsMethod · 0.65
SetConnStatsCallbackMethod · 0.65
UnlockMethod · 0.45
LockMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected