ref(models): Include event id in Event
repr
#81345
Merged
+5
−0
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.
Recently, when debugging a grouping error using Sentry, I wanted to know what event we'd been processing at the time the error was thrown, so I could examine its contents. Unfortunately, in the stack locals in the Sentry UI, all I saw was
<sentry.eventstore.models.Event object at 0x7930346ecce0>
. Fortunately, the project in question was low-traffic, so I was able to find the event based on timestamp, but it would have been a whole lot easier with the event id.This fixes that problem by adding the event id to the
Event
class's__repr__
, so now in stack locals events appear as<sentry.eventstore.models.Event at 0x125d619a0: event_id=8c567b1d65a3486da2db52695a5320d5>
.Note: I chose to keep the full path to the class in the repr - rather than following the
safe_repr
pattern we use with our DB models, under which it would just be <Event at 0x125d619a0: event_id=8c567b1d65a3486da2db52695a5320d5> - becauseEvent
isn't in fact a postgres model, and therefore doesn't live where other DB models do. As a result, I always forget where theEvent
code is, and have generally found having the full path there a helpful reminder.