Skip to content

[debugexporter] Fix profile attribute formatting#15642

Open
simonswine wants to merge 1 commit into
open-telemetry:mainfrom
simonswine:20260723_fix-sample-formatting
Open

[debugexporter] Fix profile attribute formatting#15642
simonswine wants to merge 1 commit into
open-telemetry:mainfrom
simonswine:20260723_fix-sample-formatting

Conversation

@simonswine

@simonswine simonswine commented Jul 23, 2026

Copy link
Copy Markdown

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 #15647

@simonswine
simonswine marked this pull request as ready for review July 23, 2026 16:10
@simonswine
simonswine requested review from a team and andrzej-stencel as code owners July 23, 2026 16:10
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.03%. Comparing base (52e6bf4) to head (3397947).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@simonswine
simonswine force-pushed the 20260723_fix-sample-formatting branch from a03c3a1 to 3397947 Compare July 24, 2026 09:11

@jade-guiton-dd jade-guiton-dd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, just a few suggestions. (Also, please use our issue and PR templates.)

key = dic.StringTable().At(keyIdx)
}
b.logEntry(" -> %s: %s", key, attr.Value().AsRaw())
b.logEntry(" -> %s: %v", key, attr.Value().AsRaw())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe elaborate briefly on the before and after?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[debugexporter] Format non-string profile sample attributes correctly

2 participants