in runner/utils.go [62:146]
func buildRunnerGroupSummary(s *localstore.Store, groups []*group.Handler) *types.RunnerMetricReport {
totalBytes := int64(0)
totalResp := 0
latenciesByURL := map[string]*list.List{}
errs := []types.ResponseError{}
errStats := map[string]int32{}
maxDuration := 0 * time.Second
for idx := range groups {
g := groups[idx]
pods, err := g.Pods(context.TODO())
if err != nil {
klog.V(2).ErrorS(err, "failed to list runners", "runner-group", g.Name())
continue
}
for _, pod := range pods {
data, err := readBlob(s, pod.Name)
if err != nil {
klog.V(2).ErrorS(err, "failed to read report", "runner", pod.Name)
continue
}
report := types.RunnerMetricReport{}
err = json.Unmarshal(data, &report)
if err != nil {
klog.V(2).ErrorS(err, "failed to unmarshal", "runner", pod.Name)
continue
}
// update totalReceivedBytes
totalBytes += report.TotalReceivedBytes
// update latencies
for u, l := range report.LatenciesByURL {
latencies, ok := latenciesByURL[u]
if !ok {
latenciesByURL[u] = list.New()
latencies = latenciesByURL[u]
}
for _, v := range l {
totalResp++
latencies.PushBack(v)
}
}
// update error stats
mergeErrorStat(errStats, report.ErrorStats)
errs = append(errs, report.Errors...)
report.Errors = nil
// update max duration
rDur, err := time.ParseDuration(report.Duration)
if err != nil {
klog.V(2).ErrorS(err, "failed to parse duration", "runner",
pod.Name, "duration", report.Duration)
}
if rDur > maxDuration {
maxDuration = rDur
}
}
}
percentileLatenciesByURL := map[string][][2]float64{}
latencies := make([]float64, 0, totalResp)
for u, l := range latenciesByURL {
lInSlice := listToSliceFloat64(l)
latencies = append(latencies, lInSlice...)
percentileLatenciesByURL[u] = metrics.BuildPercentileLatencies(lInSlice)
}
return &types.RunnerMetricReport{
Total: totalResp,
Errors: errs,
ErrorStats: errStats,
Duration: maxDuration.String(),
TotalReceivedBytes: totalBytes,
PercentileLatencies: metrics.BuildPercentileLatencies(latencies),
PercentileLatenciesByURL: percentileLatenciesByURL,
}
}