callstacking-rails 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1da66ff58acecfefd9f52e259cb9d69eb54e8328a4fee36ed130e26f968d61a2
4
- data.tar.gz: 2d8bc0b54633d9a17e607ee1c7006d7d728e999c5a5d5c6bfc93dd9090a1a19e
3
+ metadata.gz: 14947016af46faef4737e8800c6ea1617d81abf78076e4a072380159251c8348
4
+ data.tar.gz: 0ff0f0eae09415b28d483ca95cb5f958e106b26472020318c7a8225897203f27
5
5
  SHA512:
6
- metadata.gz: 737cf8e5ddf9467a6ce6ca2ae1ebeee369f5e9200b7893440fb923ecbe21638ac0ec0430ab909cddd29910b5a4bc83d04436fd2cf304109b88d7d64768232789
7
- data.tar.gz: 8f8afdfc52b192dd8e688e5f28dc8f93306241bc4347cc3c90144d7a6b7b9f210b0d9eb6037b288e6bbc4c68554e71456261fd736e5ea5e5fde6402c29051d53
6
+ metadata.gz: 1e33a35232719a2e04a38ae4847ac9ad09831ca41ae134568075044b040fed4e458a4de86301a5ba97fc77bea5213f02a97e78a137d33023004dfe06b48cfca5
7
+ data.tar.gz: 51f3877adb56b49a595c6ee478b89f66048aa4aa2b4e8f10c2920a4e2ead2dc16c29079cf639b62f667f2e774d6f541892cbe88c1c2c581f98262e6d19dd82ed
@@ -17,7 +17,7 @@ require "callstacking/rails/time_based_uuid"
17
17
  module Callstacking
18
18
  module Rails
19
19
  class Engine < ::Rails::Engine
20
- EXCLUDED_TEST_CLASSES = ['test/dummy/app/models/salutation.rb'].freeze
20
+ EXCLUDED_TEST_CLASSES = %w[test/dummy/app/models/salutation.rb test/dummy/app/controllers/application_controller.rb].freeze
21
21
 
22
22
  cattr_accessor :spans, :trace, :settings, :instrumenter, :loader
23
23
 
@@ -5,13 +5,12 @@ module Callstacking
5
5
  module Rails
6
6
  class Instrument
7
7
  attr_accessor :spans
8
- attr_reader :root, :settings, :span_modules
8
+ attr_reader :settings, :span_modules
9
9
 
10
10
  def initialize(spans)
11
11
  @spans = spans
12
12
  @span_modules = Set.new
13
13
  @settings = Callstacking::Rails::Settings.new
14
- @root = Regexp.new(::Rails.root.to_s)
15
14
  end
16
15
 
17
16
  def instrument_method(klass, method_name, application_level: true)
@@ -19,7 +18,7 @@ module Callstacking
19
18
  (klass.method(method_name).source_location.first rescue nil)
20
19
 
21
20
  # Application level method definitions
22
- return unless method_path =~ root if application_level
21
+ return if application_level && !(method_path =~ /#{::Rails.root.to_s}/)
23
22
 
24
23
  return if method_path =~ /initializer/i
25
24
 
@@ -82,6 +81,7 @@ module Callstacking
82
81
  instrument_klass(klass, application_level: true)
83
82
  end
84
83
  end
84
+
85
85
  def disable!
86
86
  span_modules.each do |mod|
87
87
  mod.instance_methods.each do |method_name|
@@ -91,8 +91,8 @@ module Callstacking
91
91
  end
92
92
 
93
93
  def instrument_klass(klass, application_level: true)
94
- relevant = all_methods(klass) - filtered
95
- relevant.each { |method| instrument_method(klass, method, application_level: application_level) }
94
+ relevant_methods = all_methods(klass) - filtered
95
+ relevant_methods.each { |method| instrument_method(klass, method, application_level: application_level) }
96
96
  end
97
97
 
98
98
  def self.arguments_for(m, args)
@@ -145,7 +145,6 @@ module Callstacking
145
145
  @filtered ||= (Object.instance_methods + Object.private_instance_methods +
146
146
  Object.protected_instance_methods + Object.methods(false)).uniq
147
147
  end
148
-
149
148
  end
150
149
  end
151
150
  end
@@ -3,10 +3,8 @@ require "rails"
3
3
  module Callstacking
4
4
  module Rails
5
5
  class Loader
6
- attr_accessor :root, :spans, :instrumenter, :klasses, :excluded
6
+ attr_accessor :instrumenter, :klasses, :excluded
7
7
  def initialize(instrumenter, excluded: [])
8
- @root = Regexp.new(::Rails.root.to_s)
9
- @spans = spans
10
8
  @excluded = excluded
11
9
  @instrumenter = instrumenter
12
10
  @klasses = Set.new
@@ -17,11 +15,13 @@ module Callstacking
17
15
  klass = tp.self
18
16
  path = tp.path
19
17
 
20
- exclude = excluded.any? { |ex| path =~ /#{ex}/ }
18
+ excluded_klass = excluded.any? { |ex| path =~ /#{ex}/ }
21
19
 
22
- if path =~ root && !exclude
23
- instrumenter.instrument_klass(klass)
24
- klasses << klass
20
+ if path =~ /#{::Rails.root.to_s}/ &&
21
+ !klasses.include?(klass) &&
22
+ !excluded_klass
23
+ instrumenter.instrument_klass(klass)
24
+ klasses << klass
25
25
  end
26
26
  end
27
27
 
@@ -34,7 +34,7 @@ module Callstacking
34
34
 
35
35
  start_request(trace_id, tuid,
36
36
  payload[:method], payload[:controller],
37
- payload[:action], payload[:format], ::Rails.root,
37
+ payload[:action], payload[:format], ::Rails.root.to_s,
38
38
  payload[:request]&.original_url || payload[:path],
39
39
  payload[:headers], payload[:params])
40
40
  end
@@ -1,5 +1,5 @@
1
1
  module Callstacking
2
2
  module Rails
3
- VERSION = "0.1.21"
3
+ VERSION = "0.1.23"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callstacking-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2023-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails