Skip to content

Commit

Permalink
make sure span is recording before setting attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
alizenhom committed Oct 19, 2024
1 parent bbee109 commit 9ac90f9
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ def traced_method(wrapped, instance, args, kwargs):
tool_calls=kwargs.get("tools") is not None,
)
else:
_set_response_attributes(span, result)
if span.is_recording():
_set_response_attributes(span, result)
span.end()
return result

except Exception as error:
span.set_status(Status(StatusCode.ERROR, str(error)))
span.set_attribute(
ErrorAttributes.ERROR_TYPE, type(error).__qualname__
)
if span.is_recording():
span.set_attribute(
ErrorAttributes.ERROR_TYPE, type(error).__qualname__
)
span.end()
raise

Expand Down

0 comments on commit 9ac90f9

Please sign in to comment.