( ctx context.Context, dest statsDest, networkStats map[netlogtype.Connection]netlogtype.Counts, )
| 112 | } |
| 113 | |
| 114 | func (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 | } |
no test coverage detected