(ctx context.Context, start time.Time, end time.Time, limit int, groupBy string, wheres []monitor.MonWhereItem)
| 611 | } |
| 612 | |
| 613 | func (e *executor) TopN(ctx context.Context, start time.Time, end time.Time, limit int, groupBy string, wheres []monitor.MonWhereItem) ([]*monitor.TopN, error) { |
| 614 | filters := formatFilter(wheres) |
| 615 | newStartTime, _, _, bucket := getTimeIntervalAndBucket(start, end) |
| 616 | |
| 617 | statisticsConf := []*flux.StatisticsFilterConf{ |
| 618 | { |
| 619 | Measurement: "request", |
| 620 | AggregateFn: "sum()", |
| 621 | Fields: []string{"total", "request", "response", "input_token", "output_token"}, |
| 622 | }, |
| 623 | { |
| 624 | Measurement: "proxy", |
| 625 | AggregateFn: "sum()", |
| 626 | Fields: []string{"p_total"}, |
| 627 | }, |
| 628 | } |
| 629 | |
| 630 | results, err := e.fluxQuery.CommonStatistics(ctx, e.openApi, newStartTime, end, bucket, groupBy, filters, statisticsConf, limit) |
| 631 | if err != nil { |
| 632 | return nil, err |
| 633 | } |
| 634 | topN := make([]*monitor.TopN, 0, len(results)) |
| 635 | for key, result := range results { |
| 636 | n := new(monitor.TopN) |
| 637 | n.Key = key |
| 638 | n.Request = result.Total |
| 639 | n.Token = result.TotalToken |
| 640 | n.Traffic = result.TotalRequest + result.TotalResponse |
| 641 | topN = append(topN, n) |
| 642 | } |
| 643 | |
| 644 | return topN, nil |
| 645 | } |
| 646 | |
| 647 | func (e *executor) TokenOverview(ctx context.Context, start time.Time, end time.Time, wheres []monitor.MonWhereItem) ([]time.Time, *monitor.TokenOverview, []*monitor.TokenOverview, error) { |
| 648 | newStartTime, every, windowOffset, bucket := getTimeIntervalAndBucket(start, end) |
nothing calls this directly
no test coverage detected