Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions opentelemetry-api/src/opentelemetry/attributes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,6 @@ def _clean_attribute(
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

if limit is not None and isinstance(value, str):
value = value[:limit]
return value
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-api/tests/attributes/test_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def test_sequence_attr_decode(self):
]
expected = [
None,
"Content-Disposition",
"Content-Type",
None,
"Keep-Alive",
b"Content-Disposition",
b"Content-Type",
b"\x81",
b"Keep-Alive",
]
self.assertEqual(
_clean_attribute("headers", seq, None), tuple(expected)
Expand Down