Description
Currently, the stack counters reported by telemetry use the runtime's symbol names. While they are useful information for binary-based tools, they are hostile to source-based downstream tooling because they obscure the actual package of the function name in the presence of inlining, and this information cannot be restored without type checking the source. See #64654 (comment) for an example.
I propose that x/telemetry post-processes the result of CallersFrames into a form that provides the file, (relative) line and logical (not inlined) symbol name---assuming the runtime frames provide sufficient information to make this feasible.
For example, this symbol in the current format:
golang.org/x/tools/gopls/internal/lsprpc.(*streamServer).ServeStream.ServerHandler.func3:+5
would be translated to something like:
golang.org/x/tools/gopls/internal/protocol/protocol.go:ServerHandler+5
(I suspect the name with the "true" anonymous function suffix "ServerHandler.func1" would not be available, but if it is, let's use that.)
Activity
adonovan commentedon Mar 25, 2024
Thanks to @prattmic for pointing me at: #60324. In particular, this note from Russ asserts the goal that the canonical symbol names should not be compromised by inlining. So, if that issue gets fixed, we will have reliable filenames and package names for all Go symbols, which will allow us to reliably strip off the portion of the filename to the left of the package name (e.g. /home/alice/src/).