[debugexporter] Fix profile attribute formatting#15642
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15642 +/- ##
=======================================
Coverage 91.03% 91.03%
=======================================
Files 729 729
Lines 48491 48491
=======================================
Hits 44144 44144
Misses 3020 3020
Partials 1327 1327 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The debug exporter formats profile sample attributes using %s with values returned by AsRaw(). Integer and other non-string values therefore produce malformed output such as %!s(int64=42). This changes the format verb to %v, preserving the raw attribute value while supporting all profile attribute types. Fixes open-telemetry#15647
a03c3a1 to
3397947
Compare
| key = dic.StringTable().At(keyIdx) | ||
| } | ||
| b.logEntry(" -> %s: %s", key, attr.Value().AsRaw()) | ||
| b.logEntry(" -> %s: %v", key, attr.Value().AsRaw()) |
There was a problem hiding this comment.
This is certainly better, but I think it would be even better to align with how pcommon.Values are serialized in other locations (like resource attributes) and not rely on Go's %v formatting. This would mean using the valueToString function, which looks like Str(my string) or Int(42). This would be a breaking change on the output format for strings, but we do warn in the README that "The output formats for all verbosity levels is not guaranteed and may be changed at any time without a breaking change".
| # (Optional) One or more lines of additional information to render under the primary note. | ||
| # These lines will be padded with 2 spaces and then inserted directly into the document. | ||
| # Use pipe (|) for multiline entries. | ||
| subtext: |
There was a problem hiding this comment.
Nit: Maybe elaborate briefly on the before and after?
The debug exporter formats profile sample attributes using
%swith values returned byAsRaw().Integer and other non-string values therefore produce malformed output such as
%!s(int64=42). This changes the format verb to%v, preserving the raw attribute value while supporting all profile attribute types.Fixes #15647