-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add AS::Notifications instrumentation #73
Conversation
* it didn't have tests * wrong name * bad place to set the time * will be reintroduced when ready
This reverts commit fda6334.
…doesn't have to query before save.
… model" This reverts commit 2c9d551.
…ause AR doesn't have to query before save." This reverts commit aaa9b30.
…doesn't have to query before save
Require the railtie
Updated next DDD workshop date.
And it crashed mutant with |
Rails provides quite solid framework for logging/instrumentation. We could use it to provide better insight into event handling. Popular metric tools (Datadog, Librato) can already plug into that. One could also imagine plugging log subscriber for debugging purpose. http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html http://guides.rubyonrails.org/active_support_instrumentation.html#creating-custom-events This commit adds new dispatcher, only for RailsEventStore and makes it a default. The way a new default was baked into EventBroker was driven primarily by existing linters/shared_examples and mutant - likely to be refactored. Good enough for now to start discussion about relevance of this change.
d3e518a
to
990e581
Compare
Reworked and reduced surface of changes - just another dispatcher in this PR, with little help of just released dispatcher lint. Changing default dispatcher could be another change, leaving intact now. Discussion still welcome! |
Still maintaining "describe" with class name so that mutant can match specs to changed code.
Allow logging/monitoring calls to #publish_event via AS::Notifications.
There's no other dispatcher in RailsEventStore namespace actually to name this one with specialized name.
Note to myself: check if error in subscriber of |
spec/client_spec.rb
Outdated
@@ -13,6 +13,11 @@ module RailsEventStore | |||
expect(client.__send__("event_broker")).to be_a EventBroker | |||
end | |||
|
|||
specify 'initialize proper dispatcher type' do | |||
expect(EventBroker).to receive(:new).with(dispatcher: an_instance_of(Dispatcher)) |
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.
looks a bit useless. Is it needed because mutant complains otherwise?
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.
exactly
it will be a super useful feature 👍 |
Unfortunately AS::Notifications does not swallow errors raised in subscribers and they're executed synchronously. An error in instrumentation poses a risk to rollback domain changes and event publication.
Rails provides quite solid framework for logging/instrumentation. We
could use it to provide better insight into event handling. Popular
metric tools (Datadog, Librato) can already plug into that.
One could also imagine plugging log subscriber for debugging purpose.
http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html
http://guides.rubyonrails.org/active_support_instrumentation.html#creating-custom-events
This commit adds new dispatcher, only for RailsEventStore and makes it a
default.
The way a new default was baked into EventBroker was driven primarily by
existing linters/shared_examples and mutant - likely to be refactored.
Good enough for now to start discussion about relevance of this change.