Added http method sorting to profiler
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
var (
|
||||
sortAggFields = []string{"path", "count", "size_min", "size_max", "size_avg", "time_min", "time_max", "time_avg"}
|
||||
sortRouteFields = []string{"time_start", "time_finish", "time_duration", "content_length", "http_status_code"}
|
||||
sortRouteFields = []string{"time_start", "time_finish", "time_duration", "content_length", "http_status_code", "http_method"}
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -336,6 +336,8 @@ func getSortTypeHit(s string, list *types.ApigwProfilerHitSet) sort.Interface {
|
||||
return types.ByContentLength(*list)
|
||||
case "http_status_code":
|
||||
return types.ByStatus(*list)
|
||||
case "http_method":
|
||||
return types.ByMethod(*list)
|
||||
default:
|
||||
return types.BySTime(*list)
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ type (
|
||||
ByDuration ApigwProfilerHitSet
|
||||
ByContentLength ApigwProfilerHitSet
|
||||
ByStatus ApigwProfilerHitSet
|
||||
ByMethod ApigwProfilerHitSet
|
||||
)
|
||||
|
||||
func (h ByPath) Len() int {
|
||||
@@ -285,3 +286,21 @@ func (h ByStatus) Swap(i, j int) {
|
||||
h[i], h[j] = h[j], h[i]
|
||||
return
|
||||
}
|
||||
|
||||
func (h ByMethod) Len() int {
|
||||
return len(h)
|
||||
}
|
||||
|
||||
func (h ByMethod) Less(i, j int) bool {
|
||||
// most will have the same status
|
||||
// so for paging we need a secondary sort
|
||||
if h[i].Request.Method == h[j].Request.Method {
|
||||
return h[j].Ts.After(*h[i].Ts)
|
||||
}
|
||||
return h[i].Request.Method < h[j].Request.Method
|
||||
}
|
||||
|
||||
func (h ByMethod) Swap(i, j int) {
|
||||
h[i], h[j] = h[j], h[i]
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user