Skip to content

Commit 16d6fa1

Browse files
Fix normalization bug when return value is non-dict
The changes added in #557 assumed the return value of a function will be a dictionary. In the current instrumentation, _get_catalog_dir is the exception and returns the string in which case we need the change that was originally present. This PR combines the two changes and allows the decorator to process a non-dict return_value.
1 parent 86b928f commit 16d6fa1

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

iib/common/tracing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,18 @@ def wrapper(*args, **kwargs):
120120
span.set_attribute('function_name', func.__name__)
121121
try:
122122
result = func(*args, **kwargs)
123-
span_result = normalize_data_for_span(result)
123+
if isinstance(result, dict):
124+
span_result = normalize_data_for_span(result)
125+
else:
126+
# If the returned result is not of type dict, create one
127+
span_result = {'result': result or 'success'}
124128
except Exception as exc:
125129
span.set_status(Status(StatusCode.ERROR))
126130
span.record_exception(exc)
127131
raise
128132
else:
129-
if result:
130-
log.debug('result %s', result)
133+
if span_result:
134+
log.debug('result %s', span_result)
131135
span.set_attributes(span_result)
132136
if kwargs:
133137
# Need to handle all the types of kwargs

0 commit comments

Comments
 (0)