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

Method Speedtest

codersdk/workspacesdk/agentconn.go:329–349  ·  view source on GitHub ↗

Speedtest runs a speedtest against the workspace agent.

(ctx context.Context, direction speedtest.Direction, duration time.Duration)

Source from the content-addressed store, hash-verified

327
328// Speedtest runs a speedtest against the workspace agent.
329func (c *agentConn) Speedtest(ctx context.Context, direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error) {
330 ctx, span := tracing.StartSpan(ctx)
331 defer span.End()
332
333 if !c.AwaitReachable(ctx) {
334 return nil, xerrors.Errorf("workspace agent not reachable in time: %v", ctx.Err())
335 }
336
337 c.Conn.SendConnectedTelemetry(c.agentAddress(), tailnet.TelemetryApplicationSpeedtest)
338 speedConn, err := c.Conn.DialContextTCP(ctx, netip.AddrPortFrom(c.agentAddress(), AgentSpeedtestPort))
339 if err != nil {
340 return nil, xerrors.Errorf("dial speedtest: %w", err)
341 }
342
343 results, err := speedtest.RunClientWithConn(direction, duration, speedConn)
344 if err != nil {
345 return nil, xerrors.Errorf("run speedtest: %w", err)
346 }
347
348 return results, err
349}
350
351// DialContext dials the address provided in the workspace agent.
352// The network must be "tcp" or "udp".

Callers

nothing calls this directly

Calls 7

AwaitReachableMethod · 0.95
agentAddressMethod · 0.95
StartSpanFunction · 0.92
ErrMethod · 0.80
DialContextTCPMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected