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
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:
opentelemetry-python/opentelemetry-api/src/opentelemetry/attributes/__init__.py
Lines 110 to 121 in afec2dd
Steps to Reproduce
stringValueinstead ofbytesValuein the outputExpected Result
produces
bytesValue: <bytes>Actual Result
produces
stringValue: <str>or drops the attribute with a warningAdditional context
#4118 added encoding of bytes attributes in OTLP
Would you like to implement a fix?
None