-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtrace.go
50 lines (41 loc) · 1009 Bytes
/
trace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"encoding/json"
"net/http"
"strconv"
"github.com/sarchlab/akita/v3/tracing"
)
func httpTrace(w http.ResponseWriter, r *http.Request) {
useTimeRange := true
if r.FormValue("starttime") == "" || r.FormValue("endtime") == "" {
useTimeRange = false
}
var err error
startTime := 0.0
endTime := 0.0
if useTimeRange {
startTime, err = strconv.ParseFloat(r.FormValue("starttime"), 64)
if err != nil {
panic(err)
}
endTime, err = strconv.ParseFloat(r.FormValue("endtime"), 64)
if err != nil {
panic(err)
}
}
query := tracing.TaskQuery{
ID: r.FormValue("id"),
ParentID: r.FormValue("parentid"),
Kind: r.FormValue("kind"),
Where: r.FormValue("where"),
StartTime: startTime,
EndTime: endTime,
EnableTimeRange: useTimeRange,
EnableParentTask: false,
}
tasks := traceReader.ListTasks(query)
rsp, err := json.Marshal(tasks)
dieOnErr(err)
_, err = w.Write(rsp)
dieOnErr(err)
}