golang.org/x/net/trace is the only dependency of gRPC Go that depends --
through html/template and text/template -- on reflect's MethodByName.
Binaries with MethodByName are not eligible for Go dead code
elimination.
As of protobuf v1.32.0 combined with Go 1.22, Go protobufs support
compilation with dead code elimination. This commit allows users of gRPC
Go to also make use of dead code elimination for smaller binary sizes.
Signed-off-by: Chris Koch <chrisko@google.com>
The client-side traces were otherwise only showing `RPC: to <nil>`,
which is not helpful.
Also clean up construction of traceInfo and firstLine in a few places.
Fix another bug: cancel the Context provided to an RPC server handler
as soon as that handler returns, so that goroutines started by that
handler can detect that the handler is done and exit. Without this
fix, goroutines started by a handler will keep running, unless the
handler itself arranges to cancel the context.