Skip to content

Refactor event interface construction#1296

Merged
st0012 merged 14 commits intomasterfrom
refactor-interfaces
Feb 21, 2021
Merged

Refactor event interface construction#1296
st0012 merged 14 commits intomasterfrom
refactor-interfaces

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Feb 21, 2021

  • Add StacktraceBuilder to centralize StacktraceInterface's complex construction.
    • StacktraceBuilder.build can be used to customize individual stacktrace frames.
  • Unify interface classes' construction interface - Interface.build.
    • This will also make customization easier. ATM users usually need to touch the Event class if they want to handle interfaces differently.
  • Unify construction methods' argument type to keyword arguments.
    • Because different interface requires different data to construct. Keyword argument's explicit error message will improve extension writers' developer-experience.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Feb 21, 2021

Codecov Report

Merging #1296 (8818373) into master (6e6bdd5) will decrease coverage by 20.62%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1296       +/-   ##
===========================================
- Coverage   97.95%   77.32%   -20.63%     
===========================================
  Files         203       42      -161     
  Lines        8758     1213     -7545     
===========================================
- Hits         8579      938     -7641     
- Misses        179      275       +96     
Impacted Files Coverage Δ
sentry-rails/lib/sentry-rails.rb 0.00% <0.00%> (-100.00%) ⬇️
sentry-ruby/lib/sentry/integrable.rb 0.00% <0.00%> (-100.00%) ⬇️
sentry-sidekiq/lib/sentry-sidekiq.rb 0.00% <0.00%> (-100.00%) ⬇️
sentry-sidekiq/spec/sentry/sidekiq_spec.rb 0.00% <0.00%> (-100.00%) ⬇️
sentry-sidekiq/lib/sentry/sidekiq/error_handler.rb 0.00% <0.00%> (-100.00%) ⬇️
...entry-delayed_job/lib/sentry/delayed_job/plugin.rb 0.00% <0.00%> (-100.00%) ⬇️
...entry-sidekiq/lib/sentry/sidekiq/context_filter.rb 0.00% <0.00%> (-100.00%) ⬇️
...-sidekiq/spec/sentry/sidekiq/error_handler_spec.rb 0.00% <0.00%> (-100.00%) ⬇️
...iq/lib/sentry/sidekiq/sentry_context_middleware.rb 0.00% <0.00%> (-100.00%) ⬇️
...sidekiq/spec/sentry/sidekiq/context_filter_spec.rb 0.00% <0.00%> (-93.48%) ⬇️
... and 158 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e6bdd5...8818373. Read the comment docs.

@st0012 st0012 force-pushed the refactor-interfaces branch from f6b52da to 5d42dfa Compare February 21, 2021 06:53
This moves the construction logic away from StacktraceInterface and
Event classes. It allows users to customize stacktrace construction easier.
The stacktrace interface should be attached on exception or thread
interface, not directly the event.
@st0012 st0012 force-pushed the refactor-interfaces branch from 5d42dfa to edccbe9 Compare February 21, 2021 07:09
Users can just patch SingleExceptionInterface.build_with_stacktrace to
change an exception's stacktrace.
```ruby
builder.build(backtrace) do |frame|
  if frame.module.match?(/a_gem/)
    nil
  else
    frame
  end
end
```
Keyword arguments give a more clear message on what parameters are
expected. This will help extension writers use those classes.
@st0012 st0012 force-pushed the refactor-interfaces branch from 21e3b05 to e5f22ad Compare February 21, 2021 10:01
@st0012 st0012 added this to the sentry-ruby-4.2.3 milestone Feb 21, 2021
@st0012 st0012 changed the title Refactor interface construction Refactor event interface construction Feb 21, 2021
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.

2 participants