Skip to content
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 automatic instrumentation support for callbacks #760

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Commits on Mar 1, 2024

  1. Add automatic instrumentation support for callbacks

    Callbacks can be useful but they can also be really tricky to trace and debug.
    
    This adds a new change that'll automatically log runs of `ActiveSupport::Callbacks`, such as when running jobs, saving models, delivering mailers and any other place callbacks are used.
    Note: users can disable with `config.bullet_train.instrument_callbacks = false`.
    
    Users can subscribe to `callback.active_support` if they need to do any more advanced handling with the callback:
    
    ```ruby
    ActiveSupport::Notifications.subscribe "callback.active_support" do |event|
      callback = event.payload[:callback]
      # Send to Sentry/Rollbar/HoneyBadger etc.
    end
    
    class LogSubscriber < ActiveSupport::LogSubscriber
      attach_to :active_support
    
      def callback(event)
        callback = event.payload[:callback]
        info { "Callback #{callback.full_name}: #{callback.filter} #{callback.options} from #{callback.location}".squish }
      end
    end
    ```
    kaspth authored and jagthedrummer committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    64d62a6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a388f9e View commit details
    Browse the repository at this point in the history
  3. Fix standardrb

    kaspth authored and jagthedrummer committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    cc7879d View commit details
    Browse the repository at this point in the history