go/src/cmd/trace
Michael Anthony Knyszek 49eba8b15b internal/trace: interpret string ID arguments for experimental events
Currently one of the reasons experimental events are tricky to use is
because:
- There's no way to take advantage of the existing infrastructure, like
  strings and stacks, and
- There's no way to attach arbitrary data to an event (except through
  strings, possibly).

Fix this by abstracting away the raw arguments in an ExperimentalEvent
and requiring access to the arguments via a new method, ArgValue. This
returns a Value, which gives us an opportunity to construct a typed
value for the raw argument dynamically, and a way to access existing
tables. The type of the argument is deduced from conventions for the
argument's name. This seems more than sufficient for experimental
events.

To make this work, we also need to add a "string" variant to the Value
type. This may be a little confusing since they're primarily used for
metrics, but one could imagine other scenarios in which this is useful,
such as including build information in the trace as a metric, so I think
this is fine.

This change also updates the Value API to accomodate a String method for
use with things that expect a fmt.Stringer, which means renaming the
value assertion methods to have a "To" prefix.

Change-Id: I43a2334f6cd306122c5b94641a6252ca4258b39f
Reviewed-on: https://go-review.googlesource.com/c/go/+/645135
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 11:23:31 -08:00
..
testdata internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
doc.go
gen.go internal/trace: interpret string ID arguments for experimental events 2025-02-11 11:23:31 -08:00
goroutinegen.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
goroutines.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
gstate.go internal/trace: move fake P IDs to internal/trace/traceviewer 2025-02-11 11:23:28 -08:00
jsontrace.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
jsontrace_test.go internal/trace: move fake P IDs to internal/trace/traceviewer 2025-02-11 11:23:28 -08:00
main.go internal/trace: merge event and tracev2 packages 2025-02-10 12:14:51 -08:00
pprof.go internal/trace: clean up parser.go 2025-02-11 11:23:26 -08:00
procgen.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
regions.go cmd/trace,internal/trace,runtime: refactor to access frames via range over func 2024-09-23 15:02:42 +00:00
tasks.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
threadgen.go internal/trace: move v2 tracer into trace directory 2024-05-17 18:48:18 +00:00
viewer.go internal/trace: clean up parser.go 2025-02-11 11:23:26 -08:00