aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
diff options
context:
space:
mode:
authorHana Kim <hakim@google.com>2018-03-27 14:41:19 -0400
committerHyang-Ah Hana Kim <hyangah@gmail.com>2018-03-27 19:03:54 +0000
commitaaeaad687065f45efedf2e070780b8db6ceb7f17 (patch)
tree0567fa935925222acfae616e4449d6856e478613 /src/cmd/trace
parent331c187b173e5128ed24a0670c3e5010498c1954 (diff)
downloadgo-aaeaad687065f45efedf2e070780b8db6ceb7f17.tar.gz
go-aaeaad687065f45efedf2e070780b8db6ceb7f17.zip
cmd/trace: assign a unique span id for slice representation
Spans are represented using Async Event types of chrome trace viewer. According to the doc, the 'id' should be unique within category, scope. https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.jh64i9l3vwa1 Use the index in the task's span slice as the slice id, so it can be unique within the task. The scope is the task id which is unique. This fixes a visualization bug that caused incorrect or missing presentation of nested spans. Change-Id: If1537ee00247f71fa967abfe45569a9e7dbcdce7 Reviewed-on: https://go-review.googlesource.com/102697 Reviewed-by: Heschi Kreinick <heschi@google.com>
Diffstat (limited to 'src/cmd/trace')
-rw-r--r--src/cmd/trace/trace.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/cmd/trace/trace.go b/src/cmd/trace/trace.go
index 105d10c8fb..46d67cd687 100644
--- a/src/cmd/trace/trace.go
+++ b/src/cmd/trace/trace.go
@@ -737,8 +737,8 @@ func generateTrace(params *traceParams, consumer traceConsumer) error {
ctx.emit(tEnd)
// Spans
- for _, s := range task.spans {
- ctx.emitSpan(s)
+ for i, s := range task.spans {
+ ctx.emitSpan(s, i)
}
}
}
@@ -824,7 +824,7 @@ func (ctx *traceContext) emitSlice(ev *trace.Event, name string) *ViewerEvent {
return sl
}
-func (ctx *traceContext) emitSpan(s spanDesc) {
+func (ctx *traceContext) emitSpan(s spanDesc, spanID int) {
if s.Name == "" {
return
}
@@ -837,7 +837,7 @@ func (ctx *traceContext) emitSpan(s spanDesc) {
Phase: "b",
Time: float64(s.firstTimestamp()) / 1e3,
Tid: s.G,
- ID: s.G,
+ ID: uint64(spanID),
Scope: scopeID,
Cname: colorDeepMagenta,
}
@@ -852,7 +852,7 @@ func (ctx *traceContext) emitSpan(s spanDesc) {
Phase: "e",
Time: float64(s.lastTimestamp()) / 1e3,
Tid: s.G,
- ID: s.G,
+ ID: uint64(spanID),
Scope: scopeID,
Cname: colorDeepMagenta,
}