From: Heschi Kreinick Date: Wed, 7 Mar 2018 18:54:40 +0000 (-0500) Subject: cmd/trace: filter tasks by log text X-Git-Tag: go1.11beta1~1185 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1814a0595cb62a1788e4af17c3ab71f223bbd51b;p=gostls13.git cmd/trace: filter tasks by log text Add a search box to the top of the user task views that only displays tasks containing a particular log message. Change-Id: I92f4aa113f930954e8811416901e37824f0eb884 Reviewed-on: https://go-review.googlesource.com/100843 Run-TryBot: Heschi Kreinick TryBot-Result: Gobot Gobot Reviewed-by: Hyang-Ah Hana Kim --- diff --git a/src/cmd/trace/annotations.go b/src/cmd/trace/annotations.go index aa72a50e72..677ba0366a 100644 --- a/src/cmd/trace/annotations.go +++ b/src/cmd/trace/annotations.go @@ -662,10 +662,30 @@ func newTaskFilter(r *http.Request) (*taskFilter, error) { return t.complete() && t.duration() <= lat }) } + if text := r.FormValue("logtext"); text != "" { + name = append(name, fmt.Sprintf("log contains %q", text)) + conditions = append(conditions, func(t *taskDesc) bool { + return taskMatches(t, text) + }) + } return &taskFilter{name: strings.Join(name, ","), cond: conditions}, nil } +func taskMatches(t *taskDesc, text string) bool { + for _, ev := range t.events { + switch ev.Type { + case trace.EvUserTaskCreate, trace.EvUserSpan, trace.EvUserLog: + for _, s := range ev.SArgs { + if strings.Contains(s, text) { + return true + } + } + } + } + return false +} + type durationHistogram struct { Count int Buckets []int @@ -804,6 +824,7 @@ var templUserTaskTypes = template.Must(template.New("").Parse(` +Search log text:

@@ -870,6 +891,10 @@ var templUserTaskType = template.Must(template.New("userTask").Funcs(template.Fu

User Task: {{.Name}}

+Search log text: + +
+
Task type
{{range $el := $.Entry}}
WhenElapsedGoroutine IDEvents