aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-01-28 20:54:34 +0000
committerGopher Robot <gobot@golang.org>2025-02-11 11:23:31 -0800
commit49eba8b15bcfc07eb272f23f1b6810d37e6fe342 (patch)
treecc1a340968c775d66d2ad470df666b8ccd65b2bf /src/cmd/trace
parent659b895067400e1db64c57712729623970149e99 (diff)
downloadgo-49eba8b15bcfc07eb272f23f1b6810d37e6fe342.tar.xz
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>
Diffstat (limited to 'src/cmd/trace')
-rw-r--r--src/cmd/trace/gen.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/trace/gen.go b/src/cmd/trace/gen.go
index 03ee5037e9..6e4d82799e 100644
--- a/src/cmd/trace/gen.go
+++ b/src/cmd/trace/gen.go
@@ -282,11 +282,11 @@ func (g *globalMetricGenerator) GlobalMetric(ctx *traceContext, ev *trace.Event)
m := ev.Metric()
switch m.Name {
case "/memory/classes/heap/objects:bytes":
- ctx.HeapAlloc(ctx.elapsed(ev.Time()), m.Value.Uint64())
+ ctx.HeapAlloc(ctx.elapsed(ev.Time()), m.Value.ToUint64())
case "/gc/heap/goal:bytes":
- ctx.HeapGoal(ctx.elapsed(ev.Time()), m.Value.Uint64())
+ ctx.HeapGoal(ctx.elapsed(ev.Time()), m.Value.ToUint64())
case "/sched/gomaxprocs:threads":
- ctx.Gomaxprocs(m.Value.Uint64())
+ ctx.Gomaxprocs(m.Value.ToUint64())
}
}