Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API coerces byte-valued attributes to strings #4460

Open
dimaqq opened this issue Mar 5, 2025 · 1 comment
Open

API coerces byte-valued attributes to strings #4460

dimaqq opened this issue Mar 5, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@dimaqq
Copy link
Contributor

dimaqq commented Mar 5, 2025

Describe your environment

OS: any
Python version: any
SDK version: 1.30.0
API version: 1.30.0

What happened?

OTLP proto was expanded to allow for bytes values in attributes about 3 years ago.

#4118 / #4128 implemented that in the OTLP exporter.

Unfortunately, the #4218 alone is not enough.

The bytes-valued attributes are coerced to strings way before they reach the exporter.

It happens here:

def _clean_attribute_value(
value: types.AttributeValue, limit: Optional[int]
) -> Optional[types.AttributeValue]:
if value is None:
return None
if isinstance(value, bytes):
try:
value = value.decode()
except UnicodeDecodeError:
_logger.warning("Byte attribute could not be decoded.")
return None

Steps to Reproduce

  • set attribute with bytes value that is internally string-safe
  • export
  • see stringValue instead of bytesValue in the output

Expected Result

produces bytesValue: <bytes>

Actual Result

produces stringValue: <str> or drops the attribute with a warning

Additional context

#4118 added encoding of bytes attributes in OTLP

Would you like to implement a fix?

None

@dimaqq dimaqq added the bug Something isn't working label Mar 5, 2025
@wasup-yash
Copy link
Contributor

i would be happy to resolve this too, do you have any proposed sol in mind that could be done ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants