This change protects fields mutated by Trace methods with a mutex.
In particular it fixes races caused by concurrent calls to IsError,
and viewing active traces in /debug/requests.
Includes changes from CL/67730.
Updates golang/go#24231
Change-Id: I07db54c2642efe0ea0e3ffeb54ec796ae51e70ef
Reviewed-on: https://go-review.googlesource.com/98535
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
SetMaxEvent allocates storage for all events, which is very expensive
if we want to set a high value; even with small values, the
unnecessary allocation of the initial slice is measurable.
We improve the performance by having a few events preallocated as part
of the trace, and appending as necessary. We also co-locate the flags
in event which makes it smaller (by a word).
We also add a set of benchmarks; before and after amortized cost
per-event is shown:
name old time/op new time/op delta
Trace_Default_2-32 1.19µs ± 1% 0.96µs ± 0% -18.94%
Trace_Default_10-32 579ns ± 0% 635ns ± 1% +9.82%
Trace_Default_100-32 463ns ± 1% 466ns ± 1% ~
Trace_Default_1000-32 451ns ± 1% 451ns ± 0% ~
Trace_Default_10000-32 451ns ± 2% 449ns ± 1% ~
Trace_10_2-32 1.41µs ± 1% 0.96µs ± 1% -31.74%
Trace_10_10-32 623ns ± 1% 634ns ± 1% +1.73%
Trace_10_100-32 469ns ± 1% 466ns ± 1% ~
Trace_10_1000-32 452ns ± 1% 453ns ± 2% ~
Trace_10_10000-32 451ns ± 1% 449ns ± 1% ~
Trace_100_2-32 2.78µs ± 2% 0.97µs ± 1% -65.28%
Trace_100_10-32 912ns ± 1% 637ns ± 1% -30.23%
Trace_100_100-32 479ns ± 1% 541ns ± 0% +12.77%
Trace_100_1000-32 510ns ± 0% 541ns ± 1% +6.08%
Trace_100_10000-32 514ns ± 1% 540ns ± 0% +5.14%
Trace_1000_2-32 17.2µs ± 1% 1.0µs ± 1% -94.39%
Trace_1000_10-32 3.90µs ± 1% 0.64µs ± 0% -83.68%
Trace_1000_100-32 814ns ± 1% 542ns ± 0% -33.46%
Trace_1000_1000-32 503ns ± 1% 581ns ± 0% +15.56%
Trace_1000_10000-32 1.28µs ± 2% 1.03µs ± 1% -19.68%
Change-Id: I5bbc12153a9f30dff821ef139583cb1c07a11069
Reviewed-on: https://go-review.googlesource.com/30615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Abbreviating "if and only if" to "iff" is against Go style in public
documentation; use expanded form.
Change-Id: I23afdca1b773ef9572794555dfb768c9ded90ab7
Reviewed-on: https://go-review.googlesource.com/22545
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Without this, if the responses are compressed, Chrome's content-type
detection will fail and it will attempt to download these pages rather
than render them as HTML.
Change-Id: Ib5f803f335d55a00a759de85d38855ee0ae13ee0
Reviewed-on: https://go-review.googlesource.com/18230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
These expose the main HTML rendering functions of this package
for use with alternate HTTP muxes and on alternate paths.
Fixesgolang/go#12195.
Change-Id: I679583fd26116bc83ff551a5d2a1d73ffa1e01f0
Reviewed-on: https://go-review.googlesource.com/13825
Reviewed-by: Dave Day <djd@golang.org>
An event log is typically associated with a long-lived object, like an
RPC connection. Printf calls record events; Errorf calls record
events marked as errors. The HTTP endpoint /debug/events organizes
event logs by family (usually the Go type name) and by
time-since-last-error. The expanded view shows recent events in the
log and the call stack where the event log was created.
Change-Id: I3461e0d63f39ce6495e16300299048e572b3aa19
Reviewed-on: https://go-review.googlesource.com/12025
Reviewed-by: David Symonds <dsymonds@golang.org>
These will be the standard way for inserting a Trace into a Context,
and retrieving it later. NewContext will typically only be used by
top-level context creators (e.g. the gRPC package).
Change-Id: Ifb6fc81f46a71bb965196f664714d3042a9aea18
Package trace implements tracing of requests.
It exports an HTTP interface on /debug/requests,
and higher level packages (e.g. an RPC system)
can construct and annotate traces.
Change-Id: I67e981ed28bc6a15e4ad5a02217500505896ce1c
Reviewed-on: https://go-review.googlesource.com/10741
Reviewed-by: Nigel Tao <nigeltao@golang.org>