callstacking-rails 0.1.1 → 0.1.2

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +6 -49
  4. data/app/assets/config/checkpoint_rails_manifest.js +1 -0
  5. data/app/assets/stylesheets/{callstacking → checkpoint}/rails/application.css +0 -0
  6. data/app/controllers/{callstacking → checkpoint}/rails/application_controller.rb +1 -1
  7. data/app/controllers/checkpoint/rails/traces_controller.rb +6 -0
  8. data/app/helpers/{callstacking → checkpoint}/rails/application_helper.rb +1 -1
  9. data/app/jobs/{callstacking → checkpoint}/rails/application_job.rb +1 -1
  10. data/app/mailers/{callstacking → checkpoint}/rails/application_mailer.rb +1 -1
  11. data/app/models/{callstacking → checkpoint}/rails/application_record.rb +1 -1
  12. data/config/routes.rb +1 -1
  13. data/lib/{callstacking → checkpoint}/rails/client/authenticate.rb +1 -2
  14. data/lib/{callstacking → checkpoint}/rails/client/base.rb +3 -3
  15. data/lib/{callstacking → checkpoint}/rails/client/trace.rb +1 -3
  16. data/lib/checkpoint/rails/engine.rb +34 -0
  17. data/lib/{callstacking → checkpoint}/rails/env.rb +1 -3
  18. data/lib/{callstacking → checkpoint}/rails/settings.rb +5 -13
  19. data/lib/checkpoint/rails/setup.rb +93 -0
  20. data/lib/checkpoint/rails/traceable.rb +210 -0
  21. data/lib/{callstacking → checkpoint}/rails/traces_helper.rb +7 -7
  22. data/lib/checkpoint/rails/version.rb +5 -0
  23. data/lib/checkpoint/rails.rb +7 -0
  24. metadata +40 -32
  25. data/LICENSE +0 -621
  26. data/app/assets/config/callstacking_rails_manifest.js +0 -1
  27. data/exe/callstacking-rails +0 -32
  28. data/lib/callstacking/rails/engine.rb +0 -49
  29. data/lib/callstacking/rails/instrument.rb +0 -100
  30. data/lib/callstacking/rails/loader.rb +0 -29
  31. data/lib/callstacking/rails/setup.rb +0 -115
  32. data/lib/callstacking/rails/spans.rb +0 -53
  33. data/lib/callstacking/rails/trace.rb +0 -126
  34. data/lib/callstacking/rails/version.rb +0 -5
  35. data/lib/callstacking/rails.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88265ec5da1ad5e4b040bffdb034f0abb9ff11ba7485839b1c565c774dd612ab
4
- data.tar.gz: a21ca44694d8b92e2ecba34523adc33ba1bb72c0e0d1cfdb364ba268fa1107e0
3
+ metadata.gz: f4bc78186fe09232889a12dea985d128878de745f00a7f6761fd2d6bdc1bc6e0
4
+ data.tar.gz: 113fe92740e5260af527603445de8c0ec5ce49262a332dff1620382bb584dfa3
5
5
  SHA512:
6
- metadata.gz: 99dcba1223722f85f50fb89200c408d81720028b3f7e6b9291d4a73dae5e1449a9c2152ff6baf07f890be0d718b0df1038f3c5d4b2011cce101cb56742ace0ee
7
- data.tar.gz: a545aec1de30363f71eeb4831424d65f2841292c894a50ba7d1859f820306307e2f66ec4f5a5ccade2bda14b439f1a24b40df3d57de9ede4aaa34a75bc243f5d
6
+ metadata.gz: db7b809625176d70d726b202d11d26d55c73809281af0e569431f9c884ad81ce7868e29fa685a0527a48ffc0ba8fd52cf4e35b4ae0e83bd6cf64684663bc5e31
7
+ data.tar.gz: 74cf19f86b7ad4da4c67eb1a83af54f51e843d324e067b6d05cf81eede3a1bc14a05903e252ed73359c01d0cf58a35e98940e13688fa2423abd61616ca302c6a
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2022 Jim Jones
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Callstacking::Rails
1
+ # Checkpoint::Rails
2
2
 
3
3
  Callstacking is a rolling, checkpoint debugger for Rails. It records all of the critical method calls within your app, along with their important context (param/argument/return/local variable values).
4
4
 
@@ -17,13 +17,13 @@ For method returns ↳, the final values of the local variables will be listed w
17
17
 
18
18
  Subsequent calls within a method are visibly nested.
19
19
 
20
- Callstacking is a Rails engine that you mount within your Rails app.
20
+ Checkpoint is a Rails engine that you mount within your Rails app.
21
21
 
22
22
  Here's a sample debugging sessions recorded from a Jumpstart Rails based app I've been working on. This is a request for the main page ( https://smartk.id/ ).
23
23
 
24
24
  ![image](https://user-images.githubusercontent.com/4600/190882432-58092e38-7ee2-4138-b13a-f45ff2b09227.png)
25
25
 
26
- Callstacking Rails records all of the critical method calls within your app, along with their important context (param/argument/return/local variable values).
26
+ Checkpoint Rails records all of the critical method calls within your app, along with their important context (param/argument/return/local variable values).
27
27
 
28
28
  All in a rolling panel, so that you can debug your call chains from any point in the stack.
29
29
 
@@ -42,54 +42,11 @@ And then execute:
42
42
  ```bash
43
43
  $ bundle
44
44
  ```
45
-
46
- Register an account at Callstacking.com
47
- ```bash
48
- callstacking-rails register
49
- ```
50
-
51
- Authenticate to your newly created account.
52
-
53
- ```bash
54
- callstacking-rails setup
55
- ```
56
-
57
- You're now ready to start tracing.
58
45
 
59
46
  ## Usage
60
- Usage:
61
-
62
- > callstacking-rails enable
63
-
64
- Enables the callstacking tracing.
65
-
66
- > callstacking-rails disable
67
-
68
- Disables the callstacking tracing.
69
-
70
- > callstacking-rails register
71
-
72
- Opens a browser window to register as a callstacking.com user.
73
-
74
- > callstacking-rails setup
75
-
76
- Interactively prompts you for your callstacking.com username/password.
77
- Stores auth details in `~/.callstacking`.
78
-
79
- You can have multiple environments.
80
- The default is `development`.
81
-
82
- The `development:` section in the `~/.callstacking` config contains your credentials.
83
-
84
- By setting the RAILS_ENV environment you can maintain multiple settings.
85
-
86
- Questions? Create an issue: https://github.com/callstacking/callstacking-rails/issues
87
-
88
-
89
- ## Trace Output
90
- When you open a page for your app, once the page has rendered, you will see an `<<` arrow on the right hand side.
47
+ When you open a page for your app, once the page has rendered, you will see an arrow on the right hand side.
91
48
 
92
- Click the arrows, and observe the full callstack context.
49
+ Click the arrow, and observe the full callstack context.
93
50
 
94
51
  ## License
95
- The gem is available as open source under the terms of the [GPLv3 License](https://www.gnu.org/licenses/gpl-3.0.en.html).
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/checkpoint/rails .css
@@ -1,4 +1,4 @@
1
- module Callstacking
1
+ module Checkpoint
2
2
  module Rails
3
3
  class ApplicationController < ActionController::Base
4
4
  end
@@ -0,0 +1,6 @@
1
+ module Checkpoint::Rails
2
+ class TracesController < ApplicationController
3
+ def index
4
+ end
5
+ end
6
+ end
@@ -1,4 +1,4 @@
1
- module Callstacking
1
+ module Checkpoint
2
2
  module Rails
3
3
  module ApplicationHelper
4
4
  end
@@ -1,4 +1,4 @@
1
- module Callstacking
1
+ module Checkpoint
2
2
  module Rails
3
3
  class ApplicationJob < ActiveJob::Base
4
4
  end
@@ -1,4 +1,4 @@
1
- module Callstacking
1
+ module Checkpoint
2
2
  module Rails
3
3
  class ApplicationMailer < ActionMailer::Base
4
4
  default from: "from@example.com"
@@ -1,4 +1,4 @@
1
- module Callstacking
1
+ module Checkpoint
2
2
  module Rails
3
3
  class ApplicationRecord < ActiveRecord::Base
4
4
  self.abstract_class = true
data/config/routes.rb CHANGED
@@ -1,4 +1,4 @@
1
- Callstacking::Rails::Engine.routes.draw do
1
+ Checkpoint::Rails::Engine.routes.draw do
2
2
  resources :traces
3
3
  root to: "traces#index"
4
4
  end
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
- require "callstacking/rails/client/base"
3
2
 
4
- module Callstacking
3
+ module Checkpoint
5
4
  module Rails
6
5
  module Client
7
6
  class Error < StandardError; end
@@ -1,14 +1,14 @@
1
1
  require 'faraday'
2
2
  require 'faraday/follow_redirects'
3
- require "callstacking/rails/settings"
3
+ require "checkpoint/rails/settings"
4
4
 
5
- module Callstacking
5
+ module Checkpoint
6
6
  module Rails
7
7
  module Client
8
8
  class Error < StandardError; end
9
9
 
10
10
  class Base
11
- include Callstacking::Rails::Settings
11
+ include Checkpoint::Rails::Settings
12
12
 
13
13
  def initialize
14
14
  read_settings
@@ -1,6 +1,4 @@
1
- require "callstacking/rails/client/base"
2
-
3
- module Callstacking
1
+ module Checkpoint
4
2
  module Rails
5
3
  module Client
6
4
  class Trace < Base
@@ -0,0 +1,34 @@
1
+ require "checkpoint/rails/traceable"
2
+ require "checkpoint/rails/setup"
3
+ require "checkpoint/rails/settings"
4
+ require "checkpoint/rails/client/base"
5
+ require "checkpoint/rails/client/authenticate"
6
+ require "checkpoint/rails/client/trace"
7
+ require "checkpoint/rails/traces_helper"
8
+
9
+ module Checkpoint
10
+ module Rails
11
+ class Engine < ::Rails::Engine
12
+ isolate_namespace Checkpoint::Rails
13
+
14
+ include ::Checkpoint::Rails::Traceable
15
+
16
+ initializer "engine_name.assets.precompile" do |app|
17
+ app.config.assets.precompile << "checkpoint_rails_manifest.js"
18
+ end
19
+
20
+ initializer 'local_helper.action_controller' do
21
+ ActiveSupport.on_load :action_controller do
22
+ helper Checkpoint::Rails::TracesHelper
23
+ include Checkpoint::Rails::TracesHelper
24
+ end
25
+ end
26
+
27
+ initializer :append_before_action do
28
+ ActionController::Base.send :after_action, :inject_hud
29
+ end
30
+
31
+ set_trace
32
+ end
33
+ end
34
+ end
@@ -1,6 +1,4 @@
1
- require "active_support/inflector"
2
-
3
- module Callstacking
1
+ module Checkpoint
4
2
  module Rails
5
3
  class Env
6
4
  DEFAULT_ENVIRONMENT = "development"
@@ -1,8 +1,8 @@
1
1
  require "active_support/concern"
2
2
  require "active_support/core_ext/class/attribute_accessors"
3
- require "callstacking/rails/env"
3
+ require "checkpoint/rails/env"
4
4
 
5
- module Callstacking
5
+ module Checkpoint
6
6
  module Rails
7
7
  module Settings
8
8
  extend ActiveSupport::Concern
@@ -11,7 +11,7 @@ module Callstacking
11
11
  attr_accessor :settings
12
12
  end
13
13
 
14
- SETTINGS_FILE = "#{Dir.home}/.callstacking"
14
+ SETTINGS_FILE = "#{Dir.home}/.callstacking-rails"
15
15
  PRODUCTION_URL = "https://callstacking.com"
16
16
 
17
17
  def url
@@ -30,16 +30,8 @@ module Callstacking
30
30
  File.write(SETTINGS_FILE, new_settings.to_yaml)
31
31
  end
32
32
 
33
- def enabled?
34
- settings[:enabled]
35
- end
36
-
37
- def disabled?
38
- !enabled?
39
- end
40
-
41
33
  def read_settings
42
- @@settings = @settings = complete_settings.dig(::Callstacking::Rails::Env.environment, :settings)
34
+ @@settings = @settings = complete_settings.dig(::Checkpoint::Rails::Env.environment, :settings)
43
35
  rescue StandardError => e
44
36
  puts e.full_message
45
37
  puts e.backtrace.join("\n")
@@ -47,7 +39,7 @@ module Callstacking
47
39
  end
48
40
 
49
41
  def complete_settings
50
- YAML.load(File.read(SETTINGS_FILE)) rescue {}
42
+ YAML.load(File.read(Checkpoint::Rails::Client::Base::SETTINGS_FILE)) rescue {}
51
43
  end
52
44
  end
53
45
  end
@@ -0,0 +1,93 @@
1
+ require 'yaml'
2
+ require "checkpoint/rails/settings"
3
+
4
+ module Checkpoint
5
+ module Rails
6
+ class Setup
7
+ include ::Checkpoint::Rails::Settings
8
+ extend ::Checkpoint::Rails::Settings
9
+
10
+ attr_accessor :client
11
+
12
+ def initialize
13
+ read_settings
14
+ end
15
+
16
+ def client
17
+ @client = Checkpoint::Rails::Client::Authenticate.new
18
+ end
19
+
20
+ def start
21
+ email = prompt("Enter email:")
22
+ password = prompt("Enter password:")
23
+
24
+ url = if Rails::Checkpoint::Env.production? && ENV['CHECKPOINT_RAILS_LOCAL_TEST'].nil?
25
+ PRODUCTION_URL
26
+ else
27
+ prompt("Enter URL for #{Checkpoint::Rails::Env.environment} API calls [#{PRODUCTION_URL}]:") || PRODUCTION_URL
28
+ end
29
+
30
+ save(email, password, url)
31
+
32
+ puts "Authentication successful."
33
+ puts "Settings saved to #{SETTINGS_FILE}"
34
+ rescue StandardError => e
35
+ puts "Problem authenticating: #{e.message}"
36
+ end
37
+
38
+ def prompt(label)
39
+ puts label
40
+ value = STDIN.gets.chomp
41
+ puts
42
+
43
+ return nil if value == ''
44
+ value
45
+ end
46
+
47
+ def token(email, password)
48
+ client.login(email, password)
49
+ end
50
+
51
+ def save(email, password, url)
52
+ props = { auth_token: '',
53
+ url: url,
54
+ }
55
+
56
+ props = { Checkpoint::Rails::Env.environment => {
57
+ settings: props
58
+ } }
59
+
60
+ write_settings(complete_settings.merge(props))
61
+
62
+ props[Checkpoint::Rails::Env.environment][:settings][:auth_token] = token(email, password)
63
+
64
+ write_settings(complete_settings.merge(props))
65
+
66
+ read_settings
67
+ end
68
+
69
+ def self.instructions
70
+ read_settings
71
+ puts "loading environment #{Checkpoint::Rails::Env.environment}"
72
+ puts
73
+ puts "Usage: "
74
+ puts
75
+ puts " callstacking-rails register"
76
+ puts " Opens a browser window to register as a Callstacking user."
77
+ puts
78
+ puts " callstacking-rails setup"
79
+ puts " Interactively prompts you for your Callstacking username/password, "
80
+ puts " Stores auth details in #{SETTINGS_FILE} "
81
+ puts
82
+ puts " You can have multiple environments."
83
+ puts " Default is #{Rails::Checkpoint::Env::DEFAULT_ENVIRONMENT}."
84
+ puts
85
+ puts " The #{Checkpoint::Rails::Env.environment}: section in the #{SETTINGS_FILE} contains your credentials."
86
+ puts " By setting the RAILS_ENV environment you can maintain"
87
+ puts " multiple settings."
88
+ puts
89
+ puts "Questions? Create an issue: https://github.com/callstacking/callstacking-rails/issues"
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,210 @@
1
+ require "active_support/concern"
2
+ require "checkpoint/rails/client/base"
3
+ require "checkpoint/rails/client/authenticate"
4
+ require "checkpoint/rails/client/trace"
5
+ require "checkpoint/rails/settings"
6
+
7
+ module Checkpoint
8
+ module Rails
9
+ module Traceable
10
+ extend ActiveSupport::Concern
11
+ include Checkpoint::Rails::Settings
12
+
13
+ TARGET_DIV = 'traces'
14
+
15
+ mattr_accessor :current_request_id
16
+
17
+ def set_trace
18
+ read_settings
19
+
20
+ client = Checkpoint::Rails::Client::Trace.new
21
+
22
+ trace_points = {}
23
+ params = {}
24
+ prev_event = ''
25
+ order_num = 0
26
+ trace_id = nil
27
+ traces = []
28
+ lock = Mutex.new
29
+ task = nil
30
+
31
+ ActiveSupport::Notifications.subscribe("start_processing.action_controller") do |name, start, finish, id, payload|
32
+ next if payload[:controller] == 'Checkpoint::Rails::TracesController'
33
+
34
+ key = request_key(payload)
35
+ params[key] = payload[:params]
36
+
37
+ nesting_level = -1
38
+
39
+ request_id = payload[:request].request_id
40
+ Checkpoint::Rails::Traceable.current_request_id = request_id
41
+
42
+ trace_id, _interval = client.create(payload[:method], payload[:controller],
43
+ payload[:action], payload[:format],
44
+ ::Rails.root, payload[:request].original_url,
45
+ request_id,
46
+ payload[:headers], params[key])
47
+
48
+
49
+ puts "#{settings[:url] || Checkpoint::Rails::Settings::PRODUCTION_URL}/traces/#{trace_id}"
50
+
51
+ task = Concurrent::TimerTask.new(execution_interval: 1, timeout_interval: 60) {
52
+ send_traces!(trace_id, traces, lock, client)
53
+ }
54
+
55
+ task.execute
56
+
57
+ create_message(start_request_message(payload), order_num, traces, lock)
58
+
59
+ trace_points[key]&.disable
60
+ trace_point = TracePoint.new(:call, :return) do |t|
61
+ trace = caller[0]
62
+
63
+ next unless trace.match?(Dir.pwd)
64
+
65
+ order_num += 1
66
+
67
+ if t.event == :call
68
+ nesting_level += 1
69
+
70
+ prev_event = previous_event(t)
71
+
72
+ create_call_entry(nesting_level, order_num, t, traces, lock)
73
+ elsif t.event == :return
74
+ coupled_callee = false
75
+ coupled_callee = true if prev_event == previous_event(t)
76
+
77
+ prev_event = previous_event(t)
78
+ return_value = t.return_value.inspect
79
+
80
+ create_call_return(coupled_callee, nesting_level, order_num, return_value, t, traces, lock)
81
+
82
+ nesting_level -= 1
83
+ end
84
+ end
85
+
86
+ trace_point.enable
87
+ trace_points[key] = trace_point
88
+ end
89
+
90
+ ActiveSupport::Notifications.subscribe("process_action.action_controller") do |name, start, finish, id, payload|
91
+ trace_points[request_key(payload)]&.disable
92
+ task&.shutdown
93
+
94
+ create_message(completed_request_message(payload), order_num, traces, lock)
95
+ send_traces!(trace_id, traces, lock, client)
96
+ end
97
+ end
98
+
99
+ private
100
+
101
+ def completed_request_message(payload)
102
+ "Completed request: #{payload[:method]} #{payload[:controller]}##{payload[:action]} as #{payload[:format]}"
103
+ end
104
+
105
+ def start_request_message(payload)
106
+ puts "start request message - "
107
+ "Request: #{payload[:method]} #{payload[:controller]}##{payload[:action]} as #{payload[:format]}"
108
+ end
109
+
110
+ def create_call_return(coupled_callee, nesting_level, order_num, return_value, t, traces, lock)
111
+ lock.synchronize do
112
+ traces << { trace_entry: { trace_entryable_type: 'TraceCallReturn',
113
+ order_num: order_num,
114
+ nesting_level: nesting_level,
115
+ trace_entryable_attributes: {
116
+ local_variables: locals_for(t),
117
+ klass: t.binding.receiver.class.name.to_s,
118
+ line_number: t.lineno,
119
+ path: t.path,
120
+ method_name: t.method_id,
121
+ return_value: return_value,
122
+ coupled_callee: coupled_callee,
123
+ } } }
124
+ end
125
+ end
126
+
127
+ def create_call_entry(nesting_level, order_num, t, traces, lock)
128
+ lock.synchronize do
129
+ traces << { trace_entry: { trace_entryable_type: 'TraceCallEntry',
130
+ order_num: order_num,
131
+ nesting_level: nesting_level,
132
+ trace_entryable_attributes: {
133
+ args: arguments_for(t),
134
+ klass: t.binding.receiver.class.name.to_s,
135
+ line_number: t.lineno,
136
+ path: t.path,
137
+ method_name: t.method_id,
138
+ } } }
139
+ end
140
+ end
141
+
142
+ def create_message(message, order_num, traces, lock)
143
+ lock.synchronize do
144
+ traces << { trace_entry: { trace_entryable_type: 'TraceMessage',
145
+ order_num: order_num,
146
+ nesting_level: 0,
147
+ trace_entryable_attributes: {
148
+ message: message
149
+ } } }
150
+ end
151
+ end
152
+
153
+ def send_traces!(trace_id, traces, lock, client)
154
+ lock.synchronize do
155
+ return if traces.empty?
156
+
157
+ client.upsert(trace_id, { traces: traces })
158
+ traces.clear
159
+ end
160
+ end
161
+
162
+ def caller_key(t)
163
+ "#{t.binding.receiver.class.name.to_s}##{t.method_id}"
164
+ end
165
+
166
+ def request_key(payload)
167
+ "#{payload[:controller]}##{payload[:action]}"
168
+ end
169
+
170
+ def previous_event(t)
171
+ "#{t.binding.receiver.class.name.to_s}:#{t.method_id}"
172
+ end
173
+
174
+ def view_rendered?(t)
175
+ t.path.to_s =~ /view/
176
+ end
177
+
178
+ def partial_rendered?(t)
179
+ view_rendered?(t) && Pathname.new(t.path).basename.to_s =~ /^_/
180
+ end
181
+
182
+ def layout_rendered?(t)
183
+ view_rendered?(t) && t.path =~ /layouts/
184
+ end
185
+
186
+ def template_rendered?(t)
187
+ view_rendered?(t) && !partial_rendered?(t) && !layout_rendered?(t)
188
+ end
189
+
190
+ def arguments_for(trace)
191
+ param_names = trace&.parameters&.map(&:last)
192
+ return {} if param_names.nil?
193
+
194
+ param_names.map do |param|
195
+ next if [:&, :*, :**].include?(param)
196
+ [param, trace.binding.local_variable_get(param.to_s)]
197
+ end.compact.to_h
198
+ end
199
+
200
+ def locals_for(trace)
201
+ local_names = trace&.binding&.local_variables
202
+ return {} if local_names.nil?
203
+
204
+ local_names.map do |local|
205
+ [local, trace.binding.local_variable_get(local)]
206
+ end.to_h
207
+ end
208
+ end
209
+ end
210
+ end
@@ -1,25 +1,25 @@
1
- require "action_view/helpers/tag_helper"
1
+ require "action_view/helpers/tag_helper.rb"
2
2
  require "action_view/context.rb"
3
3
 
4
- module Callstacking
4
+ module Checkpoint
5
5
  module Rails
6
6
  module TracesHelper
7
7
  include ActionView::Helpers::TagHelper
8
8
  include ActionView::Context
9
- include Callstacking::Rails::Settings
9
+ include Checkpoint::Rails::Settings
10
10
 
11
11
  def hud
12
12
  read_settings
13
13
 
14
- frame_url = "#{url || Callstacking::Rails::Settings::PRODUCTION_URL}/traces/#{Callstacking::Rails::Trace.current_request_id}/print"
14
+ frame_url = "#{url || Checkpoint::Rails::Settings::PRODUCTION_URL}/traces/#{Checkpoint::Rails::Traceable.current_request_id}/print"
15
15
 
16
16
  body = []
17
17
  body << (content_tag( :div, data: { turbo:false },
18
- style: 'top: 50%; right: 10px; font-size: 24pt; :hover{text-shadow: 1px 1px 2px #000000};
19
- padding: 0px; position: fixed; height: 50px; width: 40px; cursor: pointer;',
18
+ style: 'background-color: #FFF; color: #0000FF; font-size: 20pt; top: 50%; right: 20px;
19
+ padding: 30px 10px 0px 10px; position: fixed; height: 100px; width: 40px; cursor: pointer;',
20
20
  onclick: 'document.getElementById("callstacking-debugger").style.display = "unset";
21
21
  document.getElementById("callstacking-close").style.display = "unset";') do
22
- "💥"
22
+ ""
23
23
  end)
24
24
 
25
25
  body << (content_tag(:iframe, src: frame_url, id: 'callstacking-debugger', data: { turbo:false },
@@ -0,0 +1,5 @@
1
+ module Checkpoint
2
+ module Rails
3
+ VERSION = "0.1.2"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "checkpoint/rails/version"
2
+ require "checkpoint/rails/engine"
3
+
4
+ module Checkpoint
5
+ module Rails
6
+ end
7
+ end