Skip to content

[DO NOT MERGE] Prototype JSON representation for attribute collections - #8768

Draft
pellared wants to merge 4 commits into
open-telemetry:mainfrom
pellared:prototype-attributes-json-string
Draft

[DO NOT MERGE] Prototype JSON representation for attribute collections#8768
pellared wants to merge 4 commits into
open-telemetry:mainfrom
pellared:prototype-attributes-json-string

Conversation

@pellared

@pellared pellared commented Sep 2, 2026

Copy link
Copy Markdown
Member

Prototypes open-telemetry/opentelemetry-specification#5149 in Java.

This complements the existing Go prototypes:

What this prototypes

  • Override the built-in Attributes implementation's toString() to encode the collection as a compact JSON object.
  • Reuse the existing internal JSON encoder behind Value.asString(), including its handling of nested arrays/maps, bytes, empty values, non-finite doubles, and JSON escaping.
  • Exercise the representation through existing diagnostic consumers, notably LoggingSpanExporter and SystemOutLogRecordExporter.

For example, diagnostic output changes from:

{animal="cat", bytes=ValueBytes{AQID}, empty=ValueEmpty{}}

to:

{"animal":"cat","bytes":"AQID","empty":null}

Scope and merge status

This is intentionally a draft and marked DO NOT MERGE while the specification change is pending.

No public API or dependency is added. The repository documents toString() output as unstable. The logging/stdout exporter formats also remain diagnostic and unspecified; their updated tests demonstrate that the proposed common representation works in real exporters, not that the surrounding exporter format is now guaranteed.

This PR prototypes the Attribute Collection representation section. Java does not expose a standalone Attribute pair type, so this does not add public API solely to prototype the single-attribute section.

AI assistance

This prototype was prepared with (a huge) assistance from OpenAI Codex. 😉

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 2, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-09-02 21:38 UTC

Move out of draft to request review.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.30%. Comparing base (e2efec5) to head (4e14bc0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...pentelemetry/api/common/ArrayBackedAttributes.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8768      +/-   ##
============================================
+ Coverage     91.29%   91.30%   +0.01%     
- Complexity    10498    10502       +4     
============================================
  Files          1006     1006              
  Lines         28338    28351      +13     
  Branches       3581     3583       +2     
============================================
+ Hits          25870    25885      +15     
+ Misses         1675     1672       -3     
- Partials        793      794       +1     

☔ 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.

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.

1 participant