Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BoundedAttributes instead of raw dict to extract attributes from LogRecord #3114

Closed
findmyway opened this issue Jan 5, 2023 · 6 comments · Fixed by #3310
Closed

Use BoundedAttributes instead of raw dict to extract attributes from LogRecord #3114

findmyway opened this issue Jan 5, 2023 · 6 comments · Fixed by #3310
Assignees
Labels
bug Something isn't working good first issue Good first issue help wanted logging

Comments

@findmyway
Copy link

def _get_attributes(record: logging.LogRecord) -> Attributes:
attributes = {
k: v for k, v in vars(record).items() if k not in _RESERVED_ATTRS
}

In the latest main branch, attributes extracted from a LogRecord use dict directly. Better to use the BoundedAttributes from API to avoid some corner cases, like invalid value type or messages of long length.

@findmyway findmyway added the bug Something isn't working label Jan 5, 2023
@gdhuper
Copy link

gdhuper commented Jan 7, 2023

/assign

@gdhuper
Copy link

gdhuper commented Feb 13, 2023

@findmyway since I am new to this code base, I wanted to clarify something before I push out my PR.

In your description, you are suggesting to use BoundAttributes instead of a dict. Do you mean something like?

def _get_attributes(record: logging.LogRecord) -> BoundAttributes: 
       ...

@findmyway
Copy link
Author

Yes, and I'd also suggest using BoundAttributes in the LogRecord definition.

@lzchen lzchen added the logging label Apr 27, 2023
@srikanthccv
Copy link
Member

@gdhuper are you still working on this?

@nstawski
Copy link
Contributor

nstawski commented May 9, 2023

I would like to take this issue.

@srikanthccv srikanthccv assigned nstawski and unassigned gdhuper May 9, 2023
@gdhuper
Copy link

gdhuper commented May 9, 2023

Sorry about the inactivity on this. I ran into some build errors that I couldn't get around. Feel free to take the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment