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 17
17
import threading
18
18
from collections import OrderedDict
19
19
from collections .abc import MutableMapping
20
- from types import MappingProxyType
21
20
from typing import MutableSequence , Optional , Sequence
22
21
23
22
from opentelemetry .util import types
@@ -38,9 +37,10 @@ def _is_valid_attribute_value(value: types.AttributeValue) -> bool:
38
37
i.e. it MUST NOT contain values of different types.
39
38
"""
40
39
40
+ if isinstance (value , _VALID_ATTR_VALUE_TYPES ):
41
+ return True
42
+
41
43
if isinstance (value , Sequence ):
42
- if len (value ) == 0 :
43
- return True
44
44
45
45
sequence_first_valid_type = None
46
46
for element in value :
@@ -69,16 +69,15 @@ def _is_valid_attribute_value(value: types.AttributeValue) -> bool:
69
69
type (element ).__name__ ,
70
70
)
71
71
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
82
81
83
82
84
83
def _filter_attributes (attributes : types .Attributes ) -> None :
You can’t perform that action at this time.
0 commit comments