Skip to content

[EXPORTER] Add bytes support for OTLP recordables - #3495

Merged
marcalff merged 4 commits into
open-telemetry:mainfrom
owent:add_bytes_support_for_otlp
Jun 30, 2025
Merged

marcalff merged 4 commits into
open-telemetry:mainfrom
owent:add_bytes_support_for_otlp

Conversation

@owent

@owent owent commented Jun 24, 2025 •

Copy link
Copy Markdown
Member

Fixes #3487

Changes

  • Add bytes support for OTLP recordables.

The API interface support long time ago, but after the protos are updated, we seem to forget to implement it.
See open-telemetry/opentelemetry-specification#780 and open-telemetry/opentelemetry-proto#297 for details.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@owent
owent requested a review from a team as a code owner June 24, 2025 13:21
@netlify

netlify Bot commented Jun 24, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 55a31a3
🔍 Latest deploy log https://app.netlify.com/projects/opentelemetry-cpp-api-docs/deploys/6862ce2a2307800008bc60c6

@codecov

codecov Bot commented Jun 24, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.96%. Comparing base (7059f73) to head (55a31a3).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3495      +/-   ##
==========================================
+ Coverage   89.95%   89.96%   +0.02%     
==========================================
  Files         219      219              
  Lines        7051     7051              
==========================================
+ Hits         6342     6343       +1     
+ Misses        709      708       -1     

see 1 file with indirect coverage changes

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

@dbarker dbarker 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.

LGTM. Thanks.

@lalitb

lalitb commented Jun 24, 2025 •

Copy link
Copy Markdown
Member

Unfortunately, as a side effect, this change also enables support for populating byte/uint8 types as span attribute values, which is inconsistent with the specs:

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute

Per the spec, an attribute value MUST be one of the following:

  • string
  • boolean
  • double (IEEE 754)
  • signed 64-bit integer
  • Or an array of the above types (array must be homogeneous)

Supporting raw bytes or uint8 is not permitted for span attributes.

It’s better to enable populating uint8_t as OTLP attributes or body only for logs, not for spans.
Alternatively, instead of this PR, document that byte data should be encoded as base64 and set as a string attribute. The custom exporter or backend can handle base64 decoding if needed.

@lalitb lalitb 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.

As mentioned - #3495 (comment)

Fixes unit test: SetEmptyArrayAttribute

Fixes IWYU warnings

Only LogRecord accept bytes
@owent
owent force-pushed the add_bytes_support_for_otlp branch from 777f951 to 310964d Compare June 25, 2025 09:31
@owent

owent commented Jun 25, 2025

Copy link
Copy Markdown
Member Author

Unfortunately, as a side effect, this change also enables support for populating byte/uint8 types as span attribute values, which is inconsistent with the specs:

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute

Per the spec, an attribute value MUST be one of the following:

  • string
  • boolean
  • double (IEEE 754)
  • signed 64-bit integer
  • Or an array of the above types (array must be homogeneous)

Supporting raw bytes or uint8 is not permitted for span attributes.

It’s better to enable populating uint8_t as OTLP attributes or body only for logs, not for spans. Alternatively, instead of this PR, document that byte data should be encoded as base64 and set as a string attribute. The custom exporter or backend can handle base64 decoding if needed.

Thanks, only log record use bytes now.

@owent
owent requested a review from lalitb June 26, 2025 14:30

@lalitb lalitb 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.

Thanks.

@marcalff marcalff changed the title Add bytes support for OTLP recordables [EXPORTER] Add bytes support for OTLP recordables Jun 30, 2025
@marcalff
marcalff merged commit 22715dd into open-telemetry:main Jun 30, 2025
malkia added a commit to malkia/opentelemetry-cpp that referenced this pull request Jun 30, 2025
[EXPORTER] Add bytes support for OTLP recordables (open-telemetry#3495)
@owent
owent deleted the add_bytes_support_for_otlp branch July 1, 2025 06:43
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.

Support bytes_value type for LogRecord Body

4 participants