MCPcopy Create free account
hub / github.com/coder/coder / UserLatencyInsights

Method UserLatencyInsights

codersdk/insights.go:111–135  ·  view source on GitHub ↗
(ctx context.Context, req UserLatencyInsightsRequest)

Source from the content-addressed store, hash-verified

109}
110
111func (c *Client) UserLatencyInsights(ctx context.Context, req UserLatencyInsightsRequest) (UserLatencyInsightsResponse, error) {
112 qp := url.Values{}
113 qp.Add("start_time", req.StartTime.Format(insightsTimeLayout))
114 qp.Add("end_time", req.EndTime.Format(insightsTimeLayout))
115 if len(req.TemplateIDs) > 0 {
116 var templateIDs []string
117 for _, id := range req.TemplateIDs {
118 templateIDs = append(templateIDs, id.String())
119 }
120 qp.Add("template_ids", strings.Join(templateIDs, ","))
121 }
122
123 reqURL := fmt.Sprintf("/api/v2/insights/user-latency?%s", qp.Encode())
124 resp, err := c.Request(ctx, http.MethodGet, reqURL, nil)
125 if err != nil {
126 return UserLatencyInsightsResponse{}, xerrors.Errorf("make request: %w", err)
127 }
128 defer resp.Body.Close()
129
130 if resp.StatusCode != http.StatusOK {
131 return UserLatencyInsightsResponse{}, ReadBodyAsError(resp)
132 }
133 var result UserLatencyInsightsResponse
134 return result, json.NewDecoder(resp.Body).Decode(&result)
135}
136
137type UserActivityInsightsRequest struct {
138 StartTime time.Time `json:"start_time" format:"date-time"`

Callers 4

TestUserLatencyInsightsFunction · 0.80
TestGenericInsights_RBACFunction · 0.80

Calls 8

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
EncodeMethod · 0.80
AddMethod · 0.65
FormatMethod · 0.65
CloseMethod · 0.65
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by 4

TestUserLatencyInsightsFunction · 0.64
TestGenericInsights_RBACFunction · 0.64