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

JSON Serialization Improvements for GELFRabbitHandler #91

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

displaced
Copy link

  • Made smarter_repr smarter (handles enums and tries to use dict for other objects. Needed for my use-case of logging data from the nameko-tracer extension to the nameko microservice framework)

  • Told GELFRabbitHandler to use smarter_repr when serialising its final object

chrisp-more2 and others added 2 commits October 10, 2018 16:10
…s worker_ctx)

- Told GELFRabbitHandler to use smarter_repr when serialising its final object
Fix serialization for nameko-tracer output
@severb
Copy link
Owner

severb commented Oct 10, 2018

I don't oppose including the enum but I fear that the __dict__ case changes the log structure for others that use the current repr functionality. Thoughts?

Nit: would repr(dir(obj)) be preferrable to repr(obj.__dict__)?

@displaced
Copy link
Author

displaced commented Oct 11, 2018

I don't oppose including the enum but I fear that the __dict__ case changes the log structure for others that use the current repr functionality. Thoughts?

Ah, yes -- definitely agree. Would you be happy with wrapping the original routine in a try/except, and putting the new stuff into the except block?

[EDIT: Apologies, I was answering from memory -- the serialisation doesn't happen in that function, so the exception won't happen there -- I'll have another think!]

Nit: would repr(dir(obj)) be preferrable to repr(obj.__dict__)?

I'll give it a go -- I was concerned that dir() might grab too much detail about the object, but let's see what it looks like.

chrisp-more2 and others added 3 commits October 29, 2018 10:53
- Add introspective_repr function which uses repr(dir(obj))
- Catch TypeError in RabbitHandler's makePickle, and retry with introspective_repr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants