PrometheusMetrics returns a response from the agent's prometheus metrics endpoint
(ctx context.Context)
| 484 | |
| 485 | // PrometheusMetrics returns a response from the agent's prometheus metrics endpoint |
| 486 | func (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 |
| 505 | func (c *agentConn) ListContainers(ctx context.Context) (codersdk.WorkspaceAgentListContainersResponse, error) { |
nothing calls this directly
no test coverage detected