Skip to content

fix(zpages): use non-deprecated attribute.Value.String for formatting - #9453

Open
om7057 wants to merge 6 commits into
open-telemetry:mainfrom
om7057:fix/zpages-non-otlp-attribute-formatting
Open

fix(zpages): use non-deprecated attribute.Value.String for formatting#9453
om7057 wants to merge 6 commits into
open-telemetry:mainfrom
om7057:fix/zpages-non-otlp-attribute-formatting

Conversation

@om7057

@om7057 om7057 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #9008.

zpages formats span attributes using the deprecated attribute.Value.Emit. attribute.Value.String is the documented replacement and follows the OpenTelemetry AnyValue representation for non-OTLP protocols.

Beyond the deprecation, Emit can produce outright invalid output. For example, a float64 slice containing NaN renders as invalid: [NaN 1.5] via Emit, while String renders the spec-compliant ["NaN",1.5].

Test plan

  • Added a regression test that renders a span with a NaN-containing float64 slice attribute through the real /tracez HTTP handler and asserts the spec-compliant formatting, replacing the previous invalid: output
  • go build ./..., go vet ./..., go test ./... -race pass in zpages
  • golangci-lint run passes with 0 issues

attribute.Value.Emit is deprecated in favor of Value.String, which
implements the OpenTelemetry AnyValue representation for non-OTLP
protocols. Emit also produces invalid output for some values, e.g. a
float64 slice containing NaN renders as "invalid: [NaN 1.5]" instead
of the spec-compliant ["NaN",1.5].
@om7057
om7057 requested review from a team and dashpole as code owners August 11, 2026 03:07
The test filtered on a fixed latency bucket, but which bucket a
near-instant span lands in is timing-dependent and differs between
environments (observed passing locally, failing in CI). Use an error
span instead, which isn't latency-bucketed.
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.5%. Comparing base (b876894) to head (5068a6a).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #9453   +/-   ##
=====================================
  Coverage   84.5%   84.5%           
=====================================
  Files        203     203           
  Lines      16805   16805           
=====================================
+ Hits       14204   14213    +9     
+ Misses      2121    2114    -7     
+ Partials     480     478    -2     
Files with missing lines Coverage Δ
zpages/tracez.go 62.4% <100.0%> (+7.1%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@om7057

om7057 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@dashpole a small reminder on this!

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code change looks ok, a comment on covering regression for other cases.

Comment thread zpages/tracez_test.go
Emit and String also disagree for FLOAT64 with +/-Inf ("+Inf"/"-Inf"
vs the spec's "Infinity"/"-Infinity") and for BOOLSLICE (space- vs
comma-separated elements). Cover those alongside the original
FLOAT64SLICE/NaN case.
@om7057

om7057 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

@ps-mir I've resolved the comment, please check the changes made.

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think wantNot can be dropped, it adds conditional path only for 1 specific test which is already covered by positive assertion.

Comment thread zpages/tracez_test.go Outdated
body := w.Body.String()
assert.Contains(t, body, tc.want)
assert.NotContains(t, body, "invalid:")
if tc.wantNot != "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The positive assertion already takes care of this. I think we can remove wantNot handling here, and from the type definition above as well.

@om7057 om7057 Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, dropped wantNot and the field from the struct.

The positive want assertion already pins the exact output, so a
separate wantNot check is redundant.
@om7057

om7057 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@ps-mir done!

I think wantNot can be dropped, it adds conditional path only for 1 specific test which is already covered by positive assertion.

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requested changes to improve regression coverage are done.

Thanks for fixing this.

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.

zpages: use non-OTLP string formatting

3 participants