-
Notifications
You must be signed in to change notification settings - Fork 279
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
refactor sidekiq handler #197
Conversation
Nice, thanks @jjb! @jondeandres can you review this? |
config.server_middleware do |chain| | ||
chain.add Rollbar::Sidekiq | ||
chain.add Rollbar::SidekiqErrorHandlingMiddleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are expecting here to use Rollbar::SidekiqErrorHandler
, which is the module name you've defined above.
50c5c4f
to
c8eb84c
Compare
@jondeandres 🤦 thanks for pointing out those obvious errors -- I was tired last night when I threw that together. I've now fixed everything and also split it up into multiple commits. There are no tests for this, perhaps we can write some before merging. |
Are there tests for something else that I can look at to base tests for this off of? |
c8eb84c
to
e2e64e4
Compare
@jjb cool 👍 you can write a test for this using the inline option in sidekiq, https://github.com/mperham/sidekiq/wiki/Testing. Just write a job that will crash, enqueue it, and check that the report was sent. I'll be on freenode as 'jandres' if you want to chat it. |
@jondeandres thanks seems like the block given to i'm exploring why that might be... let me know if you have an idea |
@jondeandres okay I figured out it's because of my sidekiq test environment -- I submitted this ticket, we'll see what @mperham says sidekiq/sidekiq#2128 |
it could because this? https://github.com/mperham/sidekiq/blob/master/lib/sidekiq.rb#L53 require 'sidekiq/cli' and it should work. But now I'm thinking that perhaps middlewares will not be executed in tests environments? I've never tested Sidekiq jobs, but probably Sidekiq will have this documented. |
e2e64e4
to
3ed7ca4
Compare
@jondeandres finally got around to finishing this up, take a look |
when #209 is merged i'll rebase, for a tidier history on this one |
Thanks @jjb. Tests are failing cause sidekiq is not supported in Ruby 1.8.7, take a look at our gemspec file, https://github.com/rollbar/rollbar-gem/blob/master/rollbar.gemspec#L25. |
c76588a
to
a95b4ea
Compare
@jondeandres 1.8.6 stuff is fixed now. any idea why this lone failure happened? https://travis-ci.org/rollbar/rollbar-gem/jobs/49406361
|
@jjb is because the version of genspec: 0.2.7 https://github.com/sinisterchipmunk/genspec/blob/v0.2.7/lib/genspec.rb It seems to not be crashing in master, so probably is something in your branch. You can change gemfiles/rails40.gemfile and check that is solved:
|
@jondeandres gotcha. i increased the version for the whole project, no reason to not do this right? (after it runs i'll check it to only be for rails 4 if you prefer that) |
Nice! One comment in specs. Can you replace this style in general?
|
f5bdaa2
to
a75a1f4
Compare
This covers the core functionality of the handler. Here are ways the tests could be further improved, which I deemed not worth the effort: 1. Testing if the handler is attached properly for Rails < 3 vs. >=3. I have tested it manually for the >=3 case and it works. 2. higher level functional test in the style of how DelayedJob is tested, where actual failing jobs are queued up: https://github.com/rollbar/rollbar-gem/blob/master/spec/rollbar/delayed_job_spec.rb I didn't do this because it's more difficult to do with Sidekiq, for reasons explored here: sidekiq/sidekiq#2128
a75a1f4
to
bcee4e8
Compare
@jondeandres all set |
require 'rollbar/sidekiq' | ||
end | ||
|
||
describe "Sidekiq integration", :reconfigure_notifier => false do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be describe Rollbar::Sidekiq
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it will blow up under 1.8.7 because that class isn't loaded in lines 3-6 above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm! And can we use an string here then instead of a constant?
@jondeandres perhaps it will be more efficient for you to simply fork my branch and make the style changes you want? It's probably faster to make the changes directly than to explain to me the rationale. |
@jjb yah! probably! I'll fork this and make a PR to your repo. I hope we can merge this today. Sorry for this style comments, it's just to maintain some order here :-D. |
no problem, i enjoyed the process. |
Style changes for tests.
@jondeandres merged |
Nice! Thanks @jjb for this! |
@jondeandres were you going to merge this one today? |
Merged, thanks @jjb!! |
🍆 |
Sidekiq.configure_server do |config|
(the first one is what inspired me to do the refactoring in the first place, because in my project i need to change the behavior and currently have to do a monkeypatch which replicates all the code. after this refactoring, i can use
alias_method_chain
)let me know what you think!
/cc @dadadadave