Skip to content

Log sdk cannot add exception.message to logRecord for exceptions whose argument is an exception not a string message #4121

@hyoinandout

Description

@hyoinandout

Describe your environment

Python version: 3.12.1
SDK version: 1.25.0(e.g., 1.25.0)
API version: 1.25.0(e.g., 1.25.0)

What happened?

Warning message:
Invalid type MaxRetryError for attribute 'exception.message' value. Expected one of ["bool","str","bytes","int","float"] or a sequence of those types
occurred

This is because some exceptions from the requests package contains another exception not a string value.
And by the current logic of our sdk, we parse the exception inside an exception to exception.message attribute of logRecord.
I actually faced the below exc_info.

exc_info = 
[
<class 'requests.exceptions.ConnectionError'>,
ConnectionError(MaxRetryError("HTTPSConnectionPool(host='a.b.c', port=123): Max retries exceeded with url: /foo (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at bar456>: Failed to establish a new connection: [Errno 111] Connection refused'))")),
<traceback object at bar456>
]

Steps to Reproduce

raise an exception with another exception inside

Expected Result

This should be handled since it is from requests package - so no warning message should appear

Actual Result

A warning message appears:
Invalid type MaxRetryError for attribute 'exception.message' value. Expected one of ["bool","str","bytes","int","float"] or a sequence of those types

Additional context

No response

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions