influxdb-rails icon indicating copy to clipboard operation
influxdb-rails copied to clipboard

Use ActiveSupport::Subscriber

Open hennevogel opened this issue 3 years ago • 1 comments

We could get rid of a lot of code in InfluxDB::Rails::Railtie if we inherit from ActiveSupport::Subscriber in our own Subscriber classes and subscribe to the events in that way.

hennevogel avatar Mar 24 '21 12:03 hennevogel

And together with concurrent-ruby we could truly move out of the way of the request cycle with our stuff...

module ActionController
  class StatsSubscriber < ActiveSupport::Subscriber
    include Concurrent::Async

    attach_to :action_controller

    def process_action(event)
      async.send_instrumentation(event)
    end

    def send_instrumentation(event)
      # do our stuff...
    end
  end
end

hennevogel avatar Mar 24 '21 13:03 hennevogel