EvGoBlockGC = 42 // goroutine blocks on GC assist [timestamp, stack]
EvGCMarkAssistStart = 43 // GC mark assist start [timestamp, stack]
EvGCMarkAssistDone = 44 // GC mark assist done [timestamp]
- EvUserTaskCreate = 45 // trace.NewContext [timestamp, internal task id, internal parent id, stack, name string]
+ EvUserTaskCreate = 45 // trace.NewTask [timestamp, internal task id, internal parent id, name string, stack]
EvUserTaskEnd = 46 // end of task [timestamp, internal task id, stack]
- EvUserRegion = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), stack, name string]
+ EvUserRegion = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), name string, stack]
EvUserLog = 48 // trace.Log [timestamp, internal id, key string id, stack, value string]
EvCPUSample = 49 // CPU profiling sample [timestamp, real timestamp, real P id (-1 when absent), goroutine id, stack]
EvCount = 50
traceEvGoBlockGC = 42 // goroutine blocks on GC assist [timestamp, stack]
traceEvGCMarkAssistStart = 43 // GC mark assist start [timestamp, stack]
traceEvGCMarkAssistDone = 44 // GC mark assist done [timestamp]
- traceEvUserTaskCreate = 45 // trace.NewContext [timestamp, internal task id, internal parent task id, stack, name string]
+ traceEvUserTaskCreate = 45 // trace.NewTask [timestamp, internal task id, internal parent task id, name string, stack]
traceEvUserTaskEnd = 46 // end of a task [timestamp, internal task id, stack]
- traceEvUserRegion = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), stack, name string]
+ traceEvUserRegion = 47 // trace.WithRegion [timestamp, internal task id, mode(0:start, 1:end), name string, stack]
traceEvUserLog = 48 // trace.Log [timestamp, internal task id, key string id, stack, value string]
traceEvCPUSample = 49 // CPU profiling sample [timestamp, real timestamp, real P id (-1 when absent), goroutine id, stack]
traceEvCount = 50
categoryID, bufp := traceString(bufp, pid, category)
- extraSpace := traceBytesPerNumber + len(message) // extraSpace for the value string
+ // The log message is recorded after all of the normal trace event
+ // arguments, including the task, category, and stack IDs. We must ask
+ // traceEventLocked to reserve extra space for the length of the message
+ // and the message itself.
+ extraSpace := traceBytesPerNumber + len(message)
traceEventLocked(extraSpace, mp, pid, bufp, traceEvUserLog, 0, 3, id, categoryID)
- // traceEventLocked reserved extra space for val and len(val)
- // in buf, so buf now has room for the following.
buf := bufp.ptr()
// double-check the message and its length can fit.
// like the Go execution tracer may assume there are only a bounded
// number of unique task types in the system.
//
-// The returned end function is used to mark the task's end.
+// The returned Task's End method is used to mark the task's end.
// The trace tool measures task latency as the time between task creation
-// and when the end function is called, and provides the latency
+// and when the End method is called, and provides the latency
// distribution per task type.
-// If the end function is called multiple times, only the first
+// If the End method is called multiple times, only the first
// call is used in the latency measurement.
//
// ctx, task := trace.NewTask(ctx, "awesomeTask")
s := &Task{id: id}
return context.WithValue(pctx, traceContextKey{}, s), s
- // We allocate a new task and the end function even when
- // the tracing is disabled because the context and the detach
- // function can be used across trace enable/disable boundaries,
+ // We allocate a new task even when
+ // the tracing is disabled because the context and task
+ // can be used across trace enable/disable boundaries,
// which complicates the problem.
//
// For example, consider the following scenario:
fn()
}
-// StartRegion starts a region and returns a function for marking the
-// end of the region. The returned Region's End function must be called
+// StartRegion starts a region and returns it.
+// The returned Region's End method must be called
// from the same goroutine where the region was started.
// Within each goroutine, regions must nest. That is, regions started
// after this region must be ended before this region can be ended.