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

Implement ActiveSupport::Notifications #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisBr
Copy link

@ChrisBr ChrisBr commented Dec 16, 2020

Adding ActiveSupport Notifications similar to what ActiveRecord already does.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 96.538% when pulling 58fe921 on ChrisBr:cbruckmayer/implement-as-notifications into a84a934 on byroot:master.

@ChrisBr ChrisBr marked this pull request as ready for review December 17, 2020 10:33
@casperisfine
Copy link
Collaborator

Hum. I'm of two minds on this. On one hand it's very simple, on the other it's a bit of an overhead for something that I don't see used much.

Maybe it would make sense to have this as a module that could be optionally included when you want it?

@ChrisBr
Copy link
Author

ChrisBr commented Jan 4, 2021

Yeah, makes sense. That is what we do at the moment in Core.

  module FrozenRecordTracingPatch
    def matching_records
      ActiveSupport::Notifications.instrument('query.frozen_record', path: @klass.file_path) do
        super
      end
    end
  end
  FrozenRecord::Scope.prepend(FrozenRecordTracingPatch)

Just wanted to discuss if we wanted to include it upstream. Do you want it to include it as module here or just leave it for now?

@casperisfine
Copy link
Collaborator

Do you want it to include it as module here

I'd be fine with this. e.g. include FrozenRecord::Instrumentation

@rafaelfranca
Copy link
Collaborator

Agree we can provide an instrumentation module if people want to use without making it the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants