callstacking-rails 0.1.31 → 0.1.32

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: 26c64da0b1b2bb170e40ee319c04d9d8b090e4801d4aa61ecdb1728e4edb0a10
4
- data.tar.gz: 619d6983c3aa94affb3d31c7c0e4a8532565c219bd9d14832a50b9fb46f813b7
3
+ metadata.gz: 002a4d9f1b5077534ba5ea5dfc3b418fa77325a4028cd4ed9322803cb0200fb5
4
+ data.tar.gz: e9eb4f9d680d978e66f38f754b8c8e251e243628b8317dfa004df95545661048
5
5
  SHA512:
6
- metadata.gz: fa3fc9c4d8e079df650a5efefe6704d6682f770ebd35516ff501ddd3c896f3df69e871f7d7908855d6074c0536cff05346d31a7c74024884633c685ad3bc6909
7
- data.tar.gz: 0c253b57e8ff3044e17df80fc9bab0b3cc6cb49efc5aeba2d6900b8b27857fde19cb06fbdce5fae05da70371f6922ce7c6d4fc7419cc824c099f10df75aad7aa
6
+ metadata.gz: 70c5b03becd0e1e054a5d7142130dfce3ae8e7310a9a249ea6742a95f45b5f3f52a8f59832820c1cd981fbd556ede7f2b672de1ad56cc61e16a978a216fd0b55
7
+ data.tar.gz: 54719e4784c2c945e05eafdbc202de21c4bf425a5d0a4ce1c9403e9154851ba18a63883e2bf32712d23342cb5f9c0257d65bfd02630b9cb6bd4b58f878479baf
@@ -21,8 +21,6 @@ module Callstacking
21
21
  # https://github.com/lostisland/awesome-faraday
22
22
  @connection ||= Faraday.new(url) do |c|
23
23
  c.response :json
24
- c.use Faraday::Response::Logger
25
- # c.use Faraday::Response::Logger, nil, { headers: false, bodies: false }
26
24
  c.response :follow_redirects
27
25
  c.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
28
26
  c.request :json # This will set the "Content-Type" header to application/json and call .to_json on the body
@@ -41,11 +41,9 @@ module Callstacking
41
41
  spans[Thread.current.object_id]||=Spans.new
42
42
  instrumenter.add_span(spans[Thread.current.object_id])
43
43
 
44
- @@loader = Callstacking::Rails::Loader.new(instrumenter, excluded: settings.excluded + EXCLUDED_TEST_CLASSES)
45
- @@loader.instrument_existing
46
-
44
+ @@loader = Callstacking::Rails::Loader.new(instrumenter,
45
+ excluded: settings.excluded + EXCLUDED_TEST_CLASSES)
47
46
  loader.on_load
48
- # loader.reset!
49
47
  end
50
48
 
51
49
  # Serialize all tracing requests for now.
@@ -4,14 +4,17 @@ require "callstacking/rails/logger"
4
4
  module Callstacking
5
5
  module Rails
6
6
  class Loader
7
- attr_accessor :instrumenter, :klasses, :excluded
7
+ attr_accessor :instrumenter, :klasses, :excluded, :settings
8
8
  def initialize(instrumenter, excluded: [])
9
9
  @excluded = excluded
10
10
  @instrumenter = instrumenter
11
11
  @klasses = Set.new
12
+ @settings = Callstacking::Rails::Settings.new
13
+
14
+ preloaded_klasses
12
15
  end
13
16
 
14
- def instrument_existing
17
+ def preloaded_klasses
15
18
  ObjectSpace.each_object(Module){|ob| filter_klass(ob, (Object.const_source_location(ob.to_s)&.first rescue nil))}
16
19
  end
17
20
 
@@ -41,7 +44,7 @@ module Callstacking
41
44
  if path =~ /#{::Rails.root.to_s}/ &&
42
45
  !klasses.include?(klass) &&
43
46
  !excluded_klass
44
- instrumenter.instrument_klass(klass)
47
+ instrumenter.instrument_klass(klass) if settings.enabled?
45
48
  klasses << klass
46
49
  end
47
50
  end
@@ -23,9 +23,7 @@ module Callstacking
23
23
  end
24
24
 
25
25
  def auth_token
26
- x = ENV['CALLSTACKING_API_TOKEN'] || settings[:auth_token]
27
- raise "No auth token found. #{ENV['CALLSTACKING_API_TOKEN']} Please run `callstacking login` to get one." if x.nil?
28
- x
26
+ ENV['CALLSTACKING_API_TOKEN'] || settings[:auth_token]
29
27
  end
30
28
 
31
29
  def auth_token?
@@ -52,8 +50,8 @@ module Callstacking
52
50
  end
53
51
 
54
52
  def enabled?
55
- return Thread.current[CACHE_KEY] if Thread.current[CACHE_KEY].present?
56
53
  return ActiveRecord::Type::Boolean.new.cast(ENV[ENV_KEY]) if ENV[ENV_KEY].present?
54
+ return Thread.current[CACHE_KEY] if Thread.current[CACHE_KEY].present?
57
55
  false
58
56
  end
59
57
 
@@ -148,8 +148,6 @@ module Callstacking
148
148
  lock.synchronize do
149
149
  return if traces.empty?
150
150
 
151
- STDERR.puts "Sending #{traces.size} traces to Callstacking.io -- enabled? - #{settings.enabled?} -- #{traces.inspect}"
152
-
153
151
  client.upsert(trace_id,
154
152
  { trace_entries: traces.deep_dup })
155
153
  traces.clear
@@ -1,5 +1,5 @@
1
1
  module Callstacking
2
2
  module Rails
3
- VERSION = "0.1.31"
3
+ VERSION = "0.1.32"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callstacking-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.31
4
+ version: 0.1.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Jones