aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/trace
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-02-03 14:12:08 -0500
committerRuss Cox <rsc@golang.org>2022-04-11 16:34:30 +0000
commit19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch)
tree67dfd3e5d96250325e383183f95b6f5fe1968514 /src/runtime/trace
parent017933163ab6a2b254f0310c61b57db65cded92e (diff)
downloadgo-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.xz
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/trace')
-rw-r--r--src/runtime/trace/annotation.go16
-rw-r--r--src/runtime/trace/trace.go61
2 files changed, 38 insertions, 39 deletions
diff --git a/src/runtime/trace/annotation.go b/src/runtime/trace/annotation.go
index bf3dbc3d79..9171633b07 100644
--- a/src/runtime/trace/annotation.go
+++ b/src/runtime/trace/annotation.go
@@ -28,13 +28,13 @@ type traceContextKey struct{}
// If the end function is called multiple times, only the first
// call is used in the latency measurement.
//
-// ctx, task := trace.NewTask(ctx, "awesomeTask")
-// trace.WithRegion(ctx, "preparation", prepWork)
-// // preparation of the task
-// go func() { // continue processing the task in a separate goroutine.
-// defer task.End()
-// trace.WithRegion(ctx, "remainingWork", remainingWork)
-// }()
+// ctx, task := trace.NewTask(ctx, "awesomeTask")
+// trace.WithRegion(ctx, "preparation", prepWork)
+// // preparation of the task
+// go func() { // continue processing the task in a separate goroutine.
+// defer task.End()
+// trace.WithRegion(ctx, "remainingWork", remainingWork)
+// }()
func NewTask(pctx context.Context, taskType string) (ctx context.Context, task *Task) {
pid := fromContext(pctx).id
id := newID()
@@ -148,7 +148,7 @@ func WithRegion(ctx context.Context, regionType string, fn func()) {
// after this region must be ended before this region can be ended.
// Recommended usage is
//
-// defer trace.StartRegion(ctx, "myTracedRegion").End()
+// defer trace.StartRegion(ctx, "myTracedRegion").End()
func StartRegion(ctx context.Context, regionType string) *Region {
if !IsEnabled() {
return noopRegion
diff --git a/src/runtime/trace/trace.go b/src/runtime/trace/trace.go
index b34aef03c5..e0c3ca7a1e 100644
--- a/src/runtime/trace/trace.go
+++ b/src/runtime/trace/trace.go
@@ -5,7 +5,7 @@
// Package trace contains facilities for programs to generate traces
// for the Go execution tracer.
//
-// Tracing runtime activities
+// # Tracing runtime activities
//
// The execution trace captures a wide range of execution events such as
// goroutine creation/blocking/unblocking, syscall enter/exit/block,
@@ -19,7 +19,7 @@
// command runs the test in the current directory and writes the trace
// file (trace.out).
//
-// go test -trace=trace.out
+// go test -trace=trace.out
//
// This runtime/trace package provides APIs to add equivalent tracing
// support to a standalone program. See the Example that demonstrates
@@ -29,12 +29,12 @@
// following line will install a handler under the /debug/pprof/trace URL
// to download a live trace:
//
-// import _ "net/http/pprof"
+// import _ "net/http/pprof"
//
// See the net/http/pprof package for more details about all of the
// debug endpoints installed by this import.
//
-// User annotation
+// # User annotation
//
// Package trace provides user annotation APIs that can be used to
// log interesting events during execution.
@@ -55,16 +55,16 @@
// trace to trace the durations of sequential steps in a cappuccino making
// operation.
//
-// trace.WithRegion(ctx, "makeCappuccino", func() {
+// trace.WithRegion(ctx, "makeCappuccino", func() {
//
-// // orderID allows to identify a specific order
-// // among many cappuccino order region records.
-// trace.Log(ctx, "orderID", orderID)
+// // orderID allows to identify a specific order
+// // among many cappuccino order region records.
+// trace.Log(ctx, "orderID", orderID)
//
-// trace.WithRegion(ctx, "steamMilk", steamMilk)
-// trace.WithRegion(ctx, "extractCoffee", extractCoffee)
-// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee)
-// })
+// trace.WithRegion(ctx, "steamMilk", steamMilk)
+// trace.WithRegion(ctx, "extractCoffee", extractCoffee)
+// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee)
+// })
//
// A task is a higher-level component that aids tracing of logical
// operations such as an RPC request, an HTTP request, or an
@@ -80,27 +80,26 @@
// the trace tool can identify the goroutines involved in a specific
// cappuccino order.
//
-// ctx, task := trace.NewTask(ctx, "makeCappuccino")
-// trace.Log(ctx, "orderID", orderID)
+// ctx, task := trace.NewTask(ctx, "makeCappuccino")
+// trace.Log(ctx, "orderID", orderID)
//
-// milk := make(chan bool)
-// espresso := make(chan bool)
-//
-// go func() {
-// trace.WithRegion(ctx, "steamMilk", steamMilk)
-// milk <- true
-// }()
-// go func() {
-// trace.WithRegion(ctx, "extractCoffee", extractCoffee)
-// espresso <- true
-// }()
-// go func() {
-// defer task.End() // When assemble is done, the order is complete.
-// <-espresso
-// <-milk
-// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee)
-// }()
+// milk := make(chan bool)
+// espresso := make(chan bool)
//
+// go func() {
+// trace.WithRegion(ctx, "steamMilk", steamMilk)
+// milk <- true
+// }()
+// go func() {
+// trace.WithRegion(ctx, "extractCoffee", extractCoffee)
+// espresso <- true
+// }()
+// go func() {
+// defer task.End() // When assemble is done, the order is complete.
+// <-espresso
+// <-milk
+// trace.WithRegion(ctx, "mixMilkCoffee", mixMilkCoffee)
+// }()
//
// The trace tool computes the latency of a task by measuring the
// time between the task creation and the task end and provides