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

Pass breadcrumb context through to the background Future #175

Closed
wants to merge 5 commits into from

Conversation

nikz
Copy link
Contributor

@nikz nikz commented Apr 30, 2024

This should close #146

(NB this branches from #174, so we should merge that first)

nikz added 4 commits April 30, 2024 13:53
* Swaps to `Appraisal` gem for using different gemsets when testing
* Modify JS exception tracking injection to handle Rack::Body
* Adds Rails 7.1 dummy app and add to CI matrix
@nikz nikz requested a review from sumitramanga April 30, 2024 05:05
@nikz nikz self-assigned this Apr 30, 2024
@sumitramanga
Copy link
Collaborator

Waiting on rebase before reviewing :)

Hi, I wrote something like this into our raygun wrapper module in our application code and thought might as well see if you think more of your users would enjoy this feature.

### Contrived illustration of the problem

Instantiated and Tracked vs Instantiated, Raised, Rescued, and Tracked

#### Instantiated and Tracked

This error has `backtrace` of `nil`:

```ruby
error = StandardError.new("I'm an error")
Vydia::ErrorTracker.track_exception(error) unless some_condition?
```

vs

#### Instantiated, Raised, Rescued, and Tracked

This error has a complete `backtrace`:

```ruby
begin
  raise StandardError.new("I'm an error") unless some_condition?
rescue StandardError => error
  Vydia::ErrorTracker.track_exception(error)
end
```

### Easiest solution

- This PR makes it so if the `error` does not have a `backtrace` already, `track_exception` will call `set_backtrace` and pass in the current callstack using [Ruby `Kernel`'s `caller` method thanks to this StackOverflow post](https://stackoverflow.com/a/21620257/2696867)

#### Avoid this message on your errors in raygun portal:

> No stacktrace data is available for this error.
> Find out why script errors can contain missing details.
> If the error was manually sent then check that the data contains a properly formed error payload. Read our API documentation for more information.

## Caveats

 - Now `track_exception` is mutating its argument. This is fine for me in our application code, but probably not ideal for library code. Maybe you'd want to `.dup` the error and mutate that one instead of mutating the argument error object directly?
@nikz nikz closed this May 2, 2024
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.

Breadcrumbs don't work with send_in_background enabled
3 participants