Skip to content

Commit

Permalink
Filter native method path calls. Verson bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
aantix committed Nov 10, 2023
1 parent 46a4b56 commit ddf099d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
20 changes: 20 additions & 0 deletions lib/callstacking/rails/helpers/instrument_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,36 @@ module InstrumentHelper
extend ActiveSupport::Concern
def callstacking_setup
exception = nil
@last_callstacking_sample = TIme.utc.now
Callstacking::Rails::Engine.start_tracing(self)

yield
rescue Exception => e
@last_callstacking_exception = Time.utc.now
exception = e
raise e
ensure
Callstacking::Rails::Engine.stop_tracing(self, exception)
end
end

def callstcking_sample_trace?
if @last_callstacking_exception.present? && @last_callstacking_exception < 1.minute.ago
@last_callstacking_exception = nil
return true
end

false
end

def callstacking_followup_exception_trace?
if @last_callstacking_sample.present? && @last_callstacking_sample < 1.hour.ago
@last_callstacking_exception = nil
return true
end

false
end
end
end
end
8 changes: 4 additions & 4 deletions lib/callstacking/rails/instrument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def instrument_method(klass, method_name, application_level: true)

method_name = __method__

path = method(__method__).super_method.source_location.first
line_no = method(__method__).super_method.source_location.last
path = method(__method__).super_method.source_location&.first || ''
line_no = method(__method__).super_method.source_location&.last || ''

p, l = caller.find { |c| c.to_s =~ /#{::Rails.root.to_s}/}&.split(':')

Expand All @@ -64,8 +64,8 @@ def instrument_method(klass, method_name, application_level: true)

method_name = __method__

path = method(__method__).super_method.source_location.first
line_no = method(__method__).super_method.source_location.last
path = method(__method__).super_method.source_location&.first || ''
line_no = method(__method__).super_method.source_location&.last || ''

p, l = caller.find { |c| c.to_s =~ /#{::Rails.root.to_s}/}&.split(':')

Expand Down
2 changes: 1 addition & 1 deletion lib/callstacking/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Callstacking
module Rails
VERSION = "0.1.36"
VERSION = "0.1.37"
end
end

0 comments on commit ddf099d

Please sign in to comment.