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

Method PrometheusMetrics

codersdk/workspacesdk/agentconn.go:486–502  ·  view source on GitHub ↗

PrometheusMetrics returns a response from the agent's prometheus metrics endpoint

(ctx context.Context)

Source from the content-addressed store, hash-verified

484
485// PrometheusMetrics returns a response from the agent's prometheus metrics endpoint
486func (c *agentConn) PrometheusMetrics(ctx context.Context) ([]byte, error) {
487 ctx, span := tracing.StartSpan(ctx)
488 defer span.End()
489 res, err := c.apiRequest(ctx, http.MethodGet, "/debug/prometheus", nil)
490 if err != nil {
491 return nil, xerrors.Errorf("do request: %w", err)
492 }
493 defer res.Body.Close()
494 if res.StatusCode != http.StatusOK {
495 return nil, codersdk.ReadBodyAsError(res)
496 }
497 bs, err := io.ReadAll(res.Body)
498 if err != nil {
499 return nil, xerrors.Errorf("read response body: %w", err)
500 }
501 return bs, nil
502}
503
504// ListContainers returns a response from the agent's containers endpoint
505func (c *agentConn) ListContainers(ctx context.Context) (codersdk.WorkspaceAgentListContainersResponse, error) {

Callers

nothing calls this directly

Calls 6

apiRequestMethod · 0.95
StartSpanFunction · 0.92
ReadBodyAsErrorFunction · 0.92
CloseMethod · 0.65
ErrorfMethod · 0.45
ReadAllMethod · 0.45

Tested by

no test coverage detected