-
Notifications
You must be signed in to change notification settings - Fork 142
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 opt-in sidekiq extension for annotating delayed classes #115
base: master
Are you sure you want to change the base?
Conversation
Even if no one wants to use the extension as is, it makes a good example of how one may do it. Usage: in config/initializers/sidekiq.rb ```ruby Marginalia::SidekiqInstrumentation.enable!(annotate_delayed_class_extension: true) ``` optionally customize the `marginalia_annotate_perform` method, for example ```ruby Sidekiq::Extensions::DelayedClass.class_eval do def marginalia_annotate_perform(target, method_name, args) Rollbar.scope!(target, method_name, *args) "#{target}.#{method_name}" end end ```
@sj26 any thoughts on this? |
Sorry @bf4, I'm not sure what this is doing? Is it reaching more deeply into Sidekiq integration to craft better annotations? I really only jumped in to get automated testing working, and update marginalia to modern rails versions, not to introduce new features. 😅 |
# NOTE: Prefer redefining perform so that YAML is only parsed once. | ||
# Adding a Marginalia::Comment.components would incur an extra parsing on every query | ||
# in a delayed class | ||
def perform(yml) |
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.
@bf4 Do you have a shareable sample or example Yaml block that would be used as the input here? Is this a Sidekiq thing that has serialized values for target, method_name, and args?
if annotate_delayed_class_extension | ||
Sidekiq::Extensions::DelayedClass.class_eval do | ||
# NOTE: Prefer redefining perform so that YAML is only parsed once. | ||
# Adding a Marginalia::Comment.components would incur an extra parsing on every query |
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.
Did you have an example of an alternative to what was done here, but using the Marginalia::Comment.components mechanism that's documented to show this as a custom component?
I'm hunting for custom component examples.
Even if no one wants to use the extension as is, it makes a good example of how one may do it.
Usage: in config/initializers/sidekiq.rb
optionally customize the
marginalia_annotate_perform
method, for exampleI would have put this in the wiki entry but I couldn't edit that, and I thought this pr may be more productive than an issue or blog post.