Skip to content

Serialize event hint before passing it to the async block#1231

Merged
st0012 merged 2 commits intomasterfrom
fix-#1227
Jan 27, 2021
Merged

Serialize event hint before passing it to the async block#1231
st0012 merged 2 commits intomasterfrom
fix-#1227

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Jan 25, 2021

Event hint should also be serialized into a json-compatible hash to make sure ActiveJob can process it correctly.

Closes #1227

Event hint could contain objects that aren't supported by ActiveJob, and
that will fail the event enqueuing.
@st0012 st0012 added this to the 4.1.5 milestone Jan 25, 2021
@st0012 st0012 self-assigned this Jan 25, 2021
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 25, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.51%. Comparing base (703e4af) to head (09f5af9).
Report is 1068 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1231      +/-   ##
==========================================
+ Coverage   97.92%   98.51%   +0.59%     
==========================================
  Files         193       98      -95     
  Lines        8280     4450    -3830     
==========================================
- Hits         8108     4384    -3724     
+ Misses        172       66     -106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@st0012 st0012 modified the milestones: 4.1.5, sentry-ruby-4.1.5 Jan 27, 2021
@st0012 st0012 merged commit fa8e519 into master Jan 27, 2021
@st0012 st0012 deleted the fix-#1227 branch January 27, 2021 13:52
@agrobbin
Copy link
Copy Markdown
Contributor

@st0012 we just ran into an issue that I believe was caused by this. Serializing the hint causes the exception object to no longer be accessible to the async block, as it's been converted to JSON. We have a (temporary) check in our async block that needs to actually inspect the Exception#backtrace, and it's no longer accessible via hint[:exception] (which is what it was pre-JSON serialization).

I understand wanting to provide a serialized value that can be easily passed to SendEventJob (or some other custom Active Job-like class), so I'm wondering if there's another way for those who need to access the exception itself to do so?

@st0012
Copy link
Copy Markdown
Contributor Author

st0012 commented Mar 19, 2021

you can access the backtrace through the event payload like:

    if hint["exception"]
      exception = event["exception"]["values"].first
      stacktrace = exception["stacktrace"]["frames"]
      # which looks like this
      #
      # [
      #   {:project_root=>"/Users/st0012/projects/sentry-ruby/sentry-ruby", :abs_path=>"/some/other/path", :function=>"other_function", :lineno=>1412, :in_app=>false, :filename=>"/some/other/path"},
      #   {:project_root=>"/Users/st0012/projects/sentry-ruby/sentry-ruby", :abs_path=>"/path/to/some/file", :function=>"function_name", :lineno=>22, :in_app=>false, :filename=>"/path/to/some/file"}
      # ]
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event is not compatible with ActiveJob 6+

3 participants