Skip to content

Commit

Permalink
Merge pull request #79 from theablefew/esmarkowski/Add-instrumentation
Browse files Browse the repository at this point in the history
Add instrumentation
  • Loading branch information
esmarkowski authored Mar 15, 2024
2 parents 8b26a96 + a8c12a5 commit d64449f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ print "\t " * 7
print Rainbow(" v#{Stretchy::VERSION}").white.faint
print "\n\n"


Stretchy.instrument!

ActiveSupport::Notifications.subscribe 'search.stretchy' do |name, start, finish, id, payload|
message = [
Rainbow(" #{payload[:klass]}").bright,
Expand Down
2 changes: 2 additions & 0 deletions lib/rails/instrumentation/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module Instrumentation
class Railtie < ::Rails::Railtie

require 'rails/instrumentation/publishers'
Stretchy.instrument!

ActiveSupport::Notifications.subscribe 'search.stretchy' do |name, start, finish, id, payload|
message = [
Rainbow(" #{payload[:klass]}").bright,
Expand Down
4 changes: 4 additions & 0 deletions lib/stretchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def self.boot!
Stretchy::Attributes.register!
end

def self.instrument!
Stretchy::Delegation::GatewayDelegation.send(:include, Rails::Instrumentation::Publishers::Record)
end

module Errors
class QueryOptionMissing < StandardError; end
end
Expand Down
2 changes: 0 additions & 2 deletions lib/stretchy/delegation/gateway_delegation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ module GatewayDelegation
:count,
to: :gateway

include Rails::Instrumentation::Publishers::Record

def index_name(name=nil, &block)
if name || block_given?
return (@index_name = name || block)
Expand Down

0 comments on commit d64449f

Please sign in to comment.