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
Wrap rails runner in executor #44999
Conversation
481cfec
to
9ec2122
Compare
So it's only available through the error reporter right? I think we still don't have document for it feature yet. Do you think we can add a |
Sorry, I don't think I understand your question.
Maybe? |
I thought it'd be a new API in the Capturing it with the executor will work as well, but it also means the SDKs need to opt-in the error reporter to get it (which I think will encourage more SDKs to opt-in). However, because it's reported via the execution wrapper, we only get I hope Rails can provide more accurate source whenever possible, which in this case seems to be possible? Rails.error_reporter.record(source: "rails_runner.railties") do
# runner execution
end Wdyt? |
I don't think it's necessary. |
Also, for the user reading the report, the backtrace should make the origin of the error obvious. |
Sorry I should've explained: I'm also thinking about using the With the |
9ec2122
to
00c0b38
Compare
Ok, I think you convinced me again, so I added a distinct |
@@ -60,7 +60,7 @@ class Engine < Rails::Engine # :nodoc: | |||
initializer "action_cable.set_work_hooks" do |app| | |||
ActiveSupport.on_load(:action_cable) do | |||
ActionCable::Server::Worker.set_callback :work, :around, prepend: true do |_, inner| | |||
app.executor.wrap do | |||
app.executor.wrap(source: "unhandled_error.action_cable") 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.
To Sentry, the unhandled_error
prefix is not necessary as we'd add another tag called handled
to the event. So users can use handled
+ source
tag for searching.
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.
Right, in this case the unhandled_error
is to signal that the application, not the framework, let something bubble up.
There might be a better name for this.
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.
What do you think if we set the naming rules like [app.][feature.]<component>
. For example:
app.action_cable
- user'saction_cable
logicaction_cable
-action_cable
internal (if possible)redis_cache_store.active_support
app.runner.railties
- user's runner code
I try to mimic the same pattern as the ActiveSupport
instrumentation has. But at here the <function>
is not always available. And we need an extra flag to indicate if it's the user's code.
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'd likely go with application
over app
, it's longer, but Rails doesn't use that much. But yes I like the general idea.
Thanks for making the change, I think it'll be super helpful for our users! |
@casperisfine After this is merged, I'll push a |
The main reason is to automatically report uncaught exceptions since `rails runner` is often used for cron tasks and such.
00c0b38
to
115be62
Compare
The main reason is to automatically report uncaught exceptions since
rails runner
is often used for cron tasks and such.cc @st0012