Add repr to MessageProxy#690
Merged
Merged
Conversation
bf25c7d to
a66ba4f
Compare
LincolnPuzey
approved these changes
Apr 13, 2025
LincolnPuzey
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! Probably will be useful in any debugging scenario
Collaborator
|
Looks good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small change to improve developer experience with Dramatiq+Sentry and possibly any other error aggregation platform.
Currently error messages in Sentry look like this:
This is caused by the following code is responsible for formatting log params in Sentry: https://github.com/getsentry/sentry-python/blob/adcfa0f6abf8850f3b007bde609d0f943f621786/sentry_sdk/logger.py#L24-L32. Sentry has its reasons to do this -
__str__is more lossy than__repr__, for example exceptions stringify to their arguments, losing their class name.After this change MessageProxy repr looks as follows:
<MessageProxy Message(queue_name='default', actor_name='actor_name', args=('arg',), kwargs={}, options={}, message_id='fe5511da-59ed-4b45-80f2-526d02c935fb', message_timestamp=1743773870061)>Existing logging will not be affected because Dramatiq uses "%s" for message formatting and
MessageProxy.__str__remains the same..