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

Method RunForwarder

agent/boundarylogproxy/proxy.go:100–122  ·  view source on GitHub ↗

RunForwarder drains the log buffer and forwards logs to coderd. It blocks until ctx is canceled.

(ctx context.Context, sender Reporter)

Source from the content-addressed store, hash-verified

98// RunForwarder drains the log buffer and forwards logs to coderd.
99// It blocks until ctx is canceled.
100func (s *Server) RunForwarder(ctx context.Context, sender Reporter) error {
101 s.logger.Debug(ctx, "boundary log forwarder started")
102
103 for {
104 select {
105 case <-ctx.Done():
106 return ctx.Err()
107 case req := <-s.logs:
108 _, err := sender.ReportBoundaryLogs(ctx, req)
109 if err != nil {
110 s.logger.Warn(ctx, "failed to forward boundary logs",
111 slog.Error(err),
112 slog.F("log_count", len(req.Logs)))
113 s.metrics.batchesDropped.WithLabelValues(droppedReasonForwardFailed).Inc()
114 s.metrics.logsDropped.WithLabelValues(droppedReasonForwardFailed).Add(float64(len(req.Logs)))
115 // Continue forwarding other logs. The current batch is lost,
116 // but the socket stays alive.
117 continue
118 }
119 s.metrics.batchesForwarded.Inc()
120 }
121 }
122}
123
124func (s *Server) acceptLoop(ctx context.Context) {
125 defer s.wg.Done()

Calls 6

ErrMethod · 0.80
WithLabelValuesMethod · 0.80
ReportBoundaryLogsMethod · 0.65
AddMethod · 0.65
DoneMethod · 0.45
ErrorMethod · 0.45