Skip to content

Conversation

@lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Nov 26, 2024

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> - because Event isn't in fact a postgres model, and therefore doesn't live where other DB models do. As a result, I always forget where the Event code is, and have generally found having the full path there a helpful reminder.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 26, 2024
@codecov
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #81345   +/-   ##
=======================================
  Coverage   80.35%   80.35%           
=======================================
  Files        7219     7219           
  Lines      319567   319569    +2     
  Branches    20769    20769           
=======================================
+ Hits       256780   256783    +3     
+ Misses      62393    62392    -1     
  Partials      394      394           

@lobsterkatie lobsterkatie marked this pull request as ready for review November 26, 2024 22:51
@lobsterkatie lobsterkatie requested a review from a team as a code owner November 26, 2024 22:51
@lobsterkatie lobsterkatie merged commit 1d2c1c6 into master Nov 27, 2024
52 checks passed
@lobsterkatie lobsterkatie deleted the kmclb-add-event-id-to-event-repr branch November 27, 2024 17:32
jan-auer added a commit that referenced this pull request Nov 28, 2024
* master: (219 commits)
  fix: flatten searchable os distribution fields (#81297)
  chore(profiling): Remvoe unused profile functions metrics hook (#81396)
  fix(prompts): Properly return false instead of undefined when prompt data is null (#81404)
  fix(insights): broken screen rendering doc link (#81257)
  fix(rpc): Only groupby when needed (#81403)
  feat(grouping): Tally frame types while building exception grouping components (#81341)
  fix(similarity): Limit > 30 system frame check to Java (#81385)
  feat(alerts): Adds EAP spans results consumer configs (#81365)
  ref(insights): simplify domain view header by using tab links (#81324)
  fix(issues): Add projectId for flag onboarding on click (#81387)
  chore(flamegraphs): Remove unused legacy flamegraph code path (#81381)
  fix(performance): No table overflow + glitchy behaviour (#81378)
  feat(widget-builder): Add feature flag for redesign (#81377)
  feat(profiling): Clean up continuous profiling ui and compat flags (#81260)
  feat(visibility): Clamp date range for `TagStore` queries (#81363)
  test(taskbroker): Add CLI command for sending taskbroker tasks (#81319)
  feat(dashboards): Add ff for favouriting dashboards (#81368)
  fix(trace) match event_id by error (#81370)
  fix(insights): add missing slash on performance moving banner (#81364)
  ref(models): Include event id in `Event` repr (#81345)
  ...
andrewshie-sentry pushed a commit that referenced this pull request Dec 2, 2024
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> - because `Event` _isn't_ in fact a postgres model, and therefore doesn't live where other DB models do. As a result, I always forget where the `Event` code is, and have generally found having the full path there a helpful reminder.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants