m/n/core/rpc: shorten proto messages in traces
We'll have binary RPC logs in the future that will contain all RPC
messages. We definitely don't want kilobytes of prototext in our main
logtree or even in the RPC spans.
Change-Id: I9abc5654ce977ff97a293b04f9c1fddfb71ed4a0
Reviewed-on: https://review.monogon.dev/c/monogon/+/1425
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/core/rpc/trace.go b/metropolis/node/core/rpc/trace.go
index 65802cd..934bcc9 100644
--- a/metropolis/node/core/rpc/trace.go
+++ b/metropolis/node/core/rpc/trace.go
@@ -164,5 +164,9 @@
if err != nil {
return name
}
- return fmt.Sprintf("%s: %s", name, strings.ReplaceAll(string(bytes), "\n", " "))
+ pretty := strings.ReplaceAll(string(bytes), "\n", " ")
+ if len(pretty) > 100 {
+ pretty = pretty[:100] + "..."
+ }
+ return fmt.Sprintf("%s: %s", name, pretty)
}