https://golang.org/s/go15trace specifies user events:
Runtime/pprof package also exposes a set of functions for emission of user events:
package pprof func TraceEvent(id string) func TraceScopeStart(id string) func TraceScopeEnd(id string)
But there is no implementation at this time.
Those would be invaluable to properly debug latency problems.
(According to @dvyukov there is no one actively working on it, so I might give it a try.)
@aclements
For reference, there's been a lot of discussion about the user events API since the original proposal here: https://go-review.googlesource.com/c/8552/3/src/runtime/trace/trace.go
Also, user events came up in today's meeting with @hyangah.
Yes, I plan to work on it for go1.8 but it's possible we end up with slightly different API.
Will update this issue soon with the plan we are thinking about. @matloob
This is too late for 1.8.
@hyangah, what's the status of this? This probably needs a proposal first, I already have background and opinions of this one and can create a proposal if no one is actively working on it.
I have an old prototype of user events at https://go-review.googlesource.com/c/34031/. No effort was made to define a good API, but that could be a useful starting point for an implementation if we decide on an API.
Earlier today @heschik, @rhysh, a few others who's usernames I don't know, and I were talking about the possibility of simply using the existing profiler labels as the user spans, since they often contain exactly the request information you might want to include in a user span. (I'm not personally convinced this is a good idea, but writing it down for the record.)
I were talking about the possibility of simply using the existing profiler labels as the user spans
I don't think this is a good idea. There is an obvious possibility to annotate spans with profiler labels but we shouldn't assume they are representing the spans' themselves. In tracing, one of the fundamental features is to give to user the flexibility to be able to mark the sections they are interested in and find statistically meaningful.
FWIW is would be useful if we could understand span type, i.e. these spans are of type A (say, request processing), while these are of type B (say, database accesses). Then we could automatically infer cases of tail latency and give explanation as to why a particular span takes so long. For example, this span is the longest of its type, it has comparable with other spans of the same type cpu time, scheduler latency and network wait time, but was blocked on mutexes 10x longer.
That's what we do with goroutines today, using goroutine start function as type.
I think I get why having profiler labels create spans is undesirable, but I don't see any reason not to propagate the profiler labels to the execution trace. Concretely, just emit a trace event whenever a goroutine's labels change, and the trace viewer can attach them on all of the slices (rectangles in the UI) it emits to the JSON.
I compiled my thought in https://goo.gl/iqJfJ3
Comments are welcome.
Change https://golang.org/cl/59572 mentions this issue: runtime/trace/trace: user annotation API skeleton
Something related for the reference - some of us are doing user-level Linux-style traceevents/tracepoints in Go:
https://lab.nexedi.com/kirr/go123/blob/c0f14991/tracing/tracing.go
https://lab.nexedi.com/kirr/go123/blob/c0f14991/tracing/cmd/gotrace/gotrace.go
https://lab.nexedi.com/kirr/go123/commit/3cf17be3
https://lab.nexedi.com/kirr/go123/commit/d89b1be1
https://lab.nexedi.com/kirr/go123/commit/c0f14991
Change https://golang.org/cl/63274 mentions this issue: runtime/trace: user annotation API
Was this done in Go 1.11?
I see https://godoc.org/runtime/trace#hdr-User_annotation
Why isn't there an average for each task?
Most helpful comment
Was this done in Go 1.11?
I see https://godoc.org/runtime/trace#hdr-User_annotation