File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
opentelemetry-api/src/opentelemetry/attributes Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 1717import threading
1818from collections import OrderedDict
1919from collections .abc import MutableMapping
20- from types import MappingProxyType
2120from typing import MutableSequence , Optional , Sequence
2221
2322from opentelemetry .util import types
@@ -38,9 +37,10 @@ def _is_valid_attribute_value(value: types.AttributeValue) -> bool:
3837 i.e. it MUST NOT contain values of different types.
3938 """
4039
40+ if isinstance (value , _VALID_ATTR_VALUE_TYPES ):
41+ return True
42+
4143 if isinstance (value , Sequence ):
42- if len (value ) == 0 :
43- return True
4444
4545 sequence_first_valid_type = None
4646 for element in value :
@@ -69,16 +69,15 @@ def _is_valid_attribute_value(value: types.AttributeValue) -> bool:
6969 type (element ).__name__ ,
7070 )
7171 return False
72-
73- elif not isinstance (value , _VALID_ATTR_VALUE_TYPES ):
74- _logger .warning (
75- "Invalid type %s for attribute value. Expected one of %s or a "
76- "sequence of those types" ,
77- type (value ).__name__ ,
78- [valid_type .__name__ for valid_type in _VALID_ATTR_VALUE_TYPES ],
79- )
80- return False
81- return True
72+ return True
73+
74+ _logger .warning (
75+ "Invalid type %s for attribute value. Expected one of %s or a "
76+ "sequence of those types" ,
77+ type (value ).__name__ ,
78+ [valid_type .__name__ for valid_type in _VALID_ATTR_VALUE_TYPES ],
79+ )
80+ return False
8281
8382
8483def _filter_attributes (attributes : types .Attributes ) -> None :
You can’t perform that action at this time.
0 commit comments