Repository navigation
fix(trace-utils): accept float32-encoded doubles in the v1 decoder - #2839
Conversation
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 8a857b5 | Docs | View more details | Give us feedback! |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
BenchmarksComparisonBenchmark execution time: 2026-11-09 20:11:39 Comparing candidate commit 8a857b5 in PR branch Found 10 performance improvements and 10 performance regressions! Performance is the same for 96 metrics, 10 unstable metrics.
|
What does this PR do?
Makes the v1 trace decoder accept a double attribute value (
AnyValuetype3) encoded as msgpack float32 as well as float64. Integers and other markers are still rejected.Motivation
dd-trace-c writes a double as float32 whenever float32 holds it exactly (
1.0,2.0,43981.0, ...), saving 4 bytes per numeric attribute. It's valid msgpack, and the Agent's/v1.0/tracesdecoder accepts it. Our decoder rejected the whole payload withInvalidFormat("V1 attribute Double read failure"). Nearly every span has such an attribute (_dd.top_level = 1,_sampling_priority_v1 = 2), so in practice no dd-trace-c v1 payload could be decoded.Additional Notes
The Agent's v1 decode path, from the HTTP handler down to the double read:
/v1.0/tracesis routed tohandleTracesV1: pkg/trace/api/endpoints.go#L98-L99handleTracesV1decodes the body withdecodeConvertedTracerPayload: pkg/trace/api/api.go#L1174V10, that callsidx.InternalTracerPayload.UnmarshalMsg: pkg/trace/api/api.go#L831-L8389(attributes) is decoded byUnmarshalKeyValueMap: pkg/proto/pbgo/trace/idx/span.go#L127-L134UnmarshalAnyValue: pkg/proto/pbgo/trace/idx/span.go#L2963(double) is read withmsgp.ReadFloat64Bytes: pkg/proto/pbgo/trace/idx/span.go#L386-L393in that version,
ReadFloat64Byteswidens a float32 and rejects any other marker:Span-event attributes and array elements go through the same
unmarshalAnyValue. Our decoder also routes all of these throughread_typed_attribute_value, so the fix covers them too.How to test the change?
Describe here in detail how the change can be validated.