(ctx context.Context, start time.Time, end time.Time, wheres []monitor.MonWhereItem)
| 166 | } |
| 167 | |
| 168 | func (e *executor) ProxyTrend(ctx context.Context, start time.Time, end time.Time, wheres []monitor.MonWhereItem) (*monitor.MonInvokeCountTrend, string, error) { |
| 169 | newStartTime, every, windowOffset, bucket := getTimeIntervalAndBucket(start, end) |
| 170 | |
| 171 | filters := formatFilter(wheres) |
| 172 | |
| 173 | proxyConditions := []string{"p_total", "p_success", "p_s2xx", "p_s4xx", "p_s5xx"} |
| 174 | |
| 175 | dates, proxyValues, err := e.fluxQuery.CommonTendency(ctx, e.openApi, newStartTime, end, bucket, "proxy", filters, proxyConditions, every, windowOffset, flux.SumFn) |
| 176 | if err != nil { |
| 177 | return nil, "", err |
| 178 | } |
| 179 | proxyRate := make([]float64, 0, len(dates)) |
| 180 | //计算请求成功率 |
| 181 | proxyTotal := proxyValues["p_total"] |
| 182 | proxySuccess := proxyValues["p_success"] |
| 183 | for i, total := range proxyTotal { |
| 184 | if total == 0 { |
| 185 | proxyRate = append(proxyRate, 0) |
| 186 | continue |
| 187 | } |
| 188 | rate := FormatFloat64(float64(proxySuccess[i])/float64(total), 4) |
| 189 | proxyRate = append(proxyRate, rate) |
| 190 | } |
| 191 | |
| 192 | resultVal := &monitor.MonInvokeCountTrend{ |
| 193 | Date: dates, |
| 194 | Status5XX: proxyValues["p_s5xx"], |
| 195 | Status4XX: proxyValues["p_s4xx"], |
| 196 | ProxyRate: proxyRate, |
| 197 | ProxyTotal: proxyValues["p_total"], |
| 198 | } |
| 199 | |
| 200 | return resultVal, every, nil |
| 201 | } |
| 202 | |
| 203 | func (e *executor) InvokeTrend(ctx context.Context, start time.Time, end time.Time, wheres []monitor.MonWhereItem) (*monitor.MonInvokeCountTrend, string, error) { |
| 204 | newStartTime, every, windowOffset, bucket := getTimeIntervalAndBucket(start, end) |
nothing calls this directly
no test coverage detected