Skip to content

feat: set backtrace frame context #8

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

joshuap
Copy link
Member

@joshuap joshuap commented May 14, 2025

This uses the ProjectRoot option to set the context for the backtrace frames, which allows us to show just the application trace.

I put this together while testing the library, but my knowledge of .NET/C# is too limited to know if this will work reliably in production apps, and it needs tests. But it seems to work locally in the example app:

CleanShot 2025-05-14 at 09 50 30@2x

CleanShot 2025-05-14 at 09 55 05@2x

Sometimes we run into issues with compiled languages (I'm not sure what production stack frames look like), so this definitely needs some more manual testing to validate the approach.

Can you take a look when you get the chance, @subzero10?

Here's what we need if we move forward with this:

  • Verify approach and that it's working
  • Add tests
  • Add documentation

@subzero10
Copy link
Member

@joshuap can you please help me understand what you mean with the following:

which allows us to show just the application trace.

Maybe a screenshot of an error in HB "before" your changes and another "after" your changes?

@joshuap
Copy link
Member Author

joshuap commented May 28, 2025

@joshuap can you please help me understand what you mean with the following:

which allows us to show just the application trace.

Maybe a screenshot of an error in HB "before" your changes and another "after" your changes?

Here's an example from Ruby. Notice that the application frames (which begin with the [PROJECT_ROOT] token) are displayed first, above the full backtrace (which includes both application and vendor frames):

CleanShot 2025-05-28 at 15 05 23@2x

HB supports two ways of specifying whether a frame/file belongs to an application vs. vendor code:

  1. Substitute the absolute path to the configured project root with the [PROJECT_ROOT] token (the older method, which the Ruby gem and JS libraries use)
  2. Add the context property (not to be confused with error context) for each backtrace line in the notice payload. Values for context are "app" or "all"

We should definitely add docs for this info to the client library spec.

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.

2 participants