File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed
src/opentelemetry/attributes Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,14 @@ def _clean_extended_attribute_value(
180180 # Freeze mutable sequences defensively
181181 return tuple (cleaned_seq )
182182
183- return value
183+ try :
184+ return str (value )
185+ except Exception :
186+ raise TypeError (
187+ f"Invalid type { type (value ).__name__ } for attribute value. "
188+ f"Expected one of { [valid_type .__name__ for valid_type in _VALID_ANY_VALUE_TYPES ]} or a "
189+ "sequence of those types" ,
190+ )
184191
185192
186193def _clean_extended_attribute (
Original file line number Diff line number Diff line change @@ -319,16 +319,5 @@ def __str__(self):
319319 ) as clean_extended_attribute_mock :
320320 bdict ["request" ] = wsgi_request
321321
322- # Verify that _clean_extended_attribute was called
323- clean_extended_attribute_mock .assert_called_once ()
324-
325- # Verify that the value passed to _clean_extended_attribute is a string, not the original object
326- call_args = clean_extended_attribute_mock .call_args
327- passed_value = call_args [0 ][1 ] # Second argument is the value
328- self .assertIsInstance (passed_value , str )
329- self .assertNotEqual (
330- passed_value , original_request
331- ) # Should be stringified, not the original object
332- self .assertIn (
333- "DummyWSGIRequest" , passed_value
334- ) # String representation includes class name
322+ # Verify that the request stored in the bounded dict matches the cleaned value
323+ self .assertEqual (bdict ["request" ], "stringified_request" )
You can’t perform that action at this time.
0 commit comments