Truncate long traces for internode communication (#18593)

Prevent excessively long request traces.
This commit is contained in:
Klaus Post 2023-12-05 12:16:48 -08:00 committed by GitHub
parent 708296ae1b
commit 8fc200c0cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -129,7 +129,11 @@ func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID,
trace.HTTP.ReqInfo.Path = trace.Path
} else if v != nil {
// Print exported fields as single request to path.
trace.Path = fmt.Sprintf("%s?req=%s", trace.Path, url.QueryEscape(fmt.Sprintf("%+v", v)))
obj := fmt.Sprintf("%+v", v)
if len(obj) > 1024 {
obj = obj[:1024] + "..."
}
trace.Path = fmt.Sprintf("%s?req=%s", trace.Path, url.QueryEscape(obj))
trace.HTTP.ReqInfo.Path = trace.Path
}
t.Publisher.Publish(trace)