callstacking-rails 0.1.17 → 0.1.18

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: 2ab0ce71570b5a8fad5a52644bb6c9074397f605e534cff04bca7dc4d77e074b
4
- data.tar.gz: fbc85372f3e48c47034d8c6e91e78d609bb406aefad47f6288ddba1b20997978
3
+ metadata.gz: cd245200dbc0803435bcc4d4feca69db57741a025710058bddc434fb795bb965
4
+ data.tar.gz: 268cd85d9984c02e5a13943fcf6a14988ea0651a186c3edbbcb38570822260ce
5
5
  SHA512:
6
- metadata.gz: 2cbd1d85dd50ebbb389e1b0013015c2e0dfdeadbaede7ba8d58fe6869c798f2d8fd30902a1a3872750e751695aae3ef5ebb056146893c3a8d637058aec2ceace
7
- data.tar.gz: 7ad047325a5a029b6ba073a41905212be140be57414e88cc0e8d1a5ab30cf107c569b222ef38e18940fc92ad9ca2b6663a53b5d63b4b548f29d293d9223e7938
6
+ metadata.gz: 9a6190bfc41db5dbeddf5513f85e2dd980c650ed46b9b0b99793d529c75f8c910d7ee9777c972ffad8b0b4b109dfdda682f09f594c26b16aa9d621ebe4243d69
7
+ data.tar.gz: 7d1ee743a2fc0f384dc286acbf5865be874b5baceb5ef10c8462a7b9daa8c729d399955015a6e7ca11ea32f4d3424780c0b71d808322576c838dd4f781f15ae8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Callstacking::Rails
2
2
 
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).
3
+ Call Stacking 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
 
5
5
  You no longer need to debug with `binding.pry` or `puts` statements, as the entire callstack for a given request is captured.
6
6
 
@@ -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
+ Call Stacking 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
+ Call Stacking 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
 
@@ -43,7 +43,7 @@ And then execute:
43
43
  $ bundle
44
44
  ```
45
45
 
46
- Register an account at Callstacking.com
46
+ Register an account at callstacking.com
47
47
  ```bash
48
48
  callstacking-rails register
49
49
  ```
@@ -85,11 +85,23 @@ By setting the RAILS_ENV environment you can maintain multiple settings.
85
85
 
86
86
  Questions? Create an issue: https://github.com/callstacking/callstacking-rails/issues
87
87
 
88
+ ## Environment
89
+
90
+ You can provide the auth token via the `CALLSTACKING_AUTH_TOKEN` environment variable.
91
+
92
+ Your API token values can be viewed at https://callstacking.com/api_tokens
93
+
94
+ You can enable/disable tracing via the `CALLSTACKING_ENABLED` environment variable (false|true).
88
95
 
89
96
  ## 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.
97
+ When you open a page for your app, once the page has rendered, you will see a `💥` icon on the right hand side.
98
+
99
+ Click the icon and observe the full callstack context.
91
100
 
92
- Click the arrows, and observe the full callstack context.
101
+ ## Tests
102
+ ``
103
+ rake app:test:all
104
+ ``
93
105
 
94
106
  ## License
95
107
  The gem is available as open source under the terms of the [GPLv3 License](https://www.gnu.org/licenses/gpl-3.0.en.html).
@@ -17,16 +17,16 @@ read_settings
17
17
 
18
18
  case action
19
19
  when 'register'
20
- `open #{settings[:url] || Callstacking::Rails::Settings::PRODUCTION_URL}/users/sign_up`
20
+ `open #{settings[:url]}/users/sign_up`
21
21
 
22
22
  when 'setup'
23
23
  Callstacking::Rails::Setup.new.start
24
24
 
25
25
  when 'enable'
26
26
  Callstacking::Rails::Setup.new.enable_disable
27
- puts "Callstacking tracing enabled (#{Callstacking::Rails::Env.environment})"
27
+ puts "Call Stacking tracing enabled (#{Callstacking::Rails::Env.environment})"
28
28
 
29
29
  when 'disable'
30
30
  Callstacking::Rails::Setup.new.enable_disable(enabled: false)
31
- puts "Callstacking tracing disabled (#{Callstacking::Rails::Env.environment})"
31
+ puts "Call Stacking tracing disabled (#{Callstacking::Rails::Env.environment})"
32
32
  end
@@ -13,13 +13,15 @@ require "callstacking/rails/traces_helper"
13
13
  module Callstacking
14
14
  module Rails
15
15
  class Engine < ::Rails::Engine
16
+ cattr_accessor :spans, :trace
17
+
16
18
  include Settings
17
19
  isolate_namespace Callstacking::Rails
18
20
 
19
21
  read_settings
20
22
 
21
- spans = Spans.new
22
- trace = Trace.new(spans)
23
+ @@spans||=Spans.new
24
+ @@trace||=Trace.new(@@spans)
23
25
 
24
26
  initializer "engine_name.assets.precompile" do |app|
25
27
  app.config.assets.precompile << "checkpoint_rails_manifest.js"
@@ -30,7 +32,7 @@ module Callstacking
30
32
  include Callstacking::Rails::TracesHelper
31
33
  end
32
34
 
33
- Callstacking::Rails::Loader.new.on_load(spans) if enabled?
35
+ Callstacking::Rails::Loader.new.on_load(@@spans) if enabled?
34
36
  end
35
37
 
36
38
  initializer :append_before_action do
@@ -38,10 +40,10 @@ module Callstacking
38
40
  end
39
41
 
40
42
  if enabled?
41
- puts "Callstacking enabled (#{Callstacking::Rails::Env.environment})"
43
+ puts "Call Stacking enabled (#{Callstacking::Rails::Env.environment})"
42
44
  trace.tracing
43
45
  else
44
- puts "Callstacking disabled (#{Callstacking::Rails::Env.environment})"
46
+ puts "Call Stacking disabled (#{Callstacking::Rails::Env.environment})"
45
47
  end
46
48
  end
47
49
  end
@@ -15,11 +15,11 @@ module Callstacking
15
15
  PRODUCTION_URL = "https://callstacking.com"
16
16
 
17
17
  def url
18
- settings[:url]
18
+ settings[:url] || PRODUCTION_URL
19
19
  end
20
20
 
21
21
  def auth_token
22
- settings[:auth_token]
22
+ ENV['CALLSTACKING_API_TOKEN'] || settings[:auth_token]
23
23
  end
24
24
 
25
25
  def auth_token?
@@ -27,18 +27,15 @@ module Callstacking
27
27
  email = prompt("Enter email:")
28
28
  password = prompt("Enter password:", echo: false)
29
29
 
30
- url = if Callstacking::Rails::Env.production? && ENV['CHECKPOINT_RAILS_LOCAL_TEST'].nil?
31
- PRODUCTION_URL
32
- else
33
- prompt("Enter URL for #{Callstacking::Rails::Env.environment} API calls [#{PRODUCTION_URL}]:") || PRODUCTION_URL
34
- end
35
-
36
30
  save(email, password, url)
37
31
 
38
32
  puts "Authentication successful."
39
33
  puts "Settings saved to #{SETTINGS_FILE}"
34
+ true
40
35
  rescue StandardError => e
41
36
  puts "Problem authenticating: #{e.message}"
37
+ puts e.backtrace.join("\n")
38
+ false
42
39
  end
43
40
 
44
41
  def enable_disable(enabled: true)
@@ -54,11 +51,7 @@ module Callstacking
54
51
  def prompt(label, echo: true)
55
52
  puts label
56
53
 
57
- value = if echo
58
- STDIN.gets.chomp
59
- else
60
- STDIN.noecho(&:gets).chomp
61
- end
54
+ value = echo ? STDIN.gets.chomp : STDIN.noecho(&:gets).chomp
62
55
  puts
63
56
 
64
57
  return nil if value == ''
@@ -119,6 +112,16 @@ module Callstacking
119
112
  puts
120
113
  puts "Questions? Create an issue: https://github.com/callstacking/callstacking-rails/issues"
121
114
  end
115
+
116
+ private
117
+
118
+ def url
119
+ if Callstacking::Rails::Env.production? && ENV['CALLSTACKING_RAILS_LOCAL_TEST'].nil?
120
+ PRODUCTION_URL
121
+ else
122
+ prompt("Enter URL for #{Callstacking::Rails::Env.environment} API calls [#{PRODUCTION_URL}]:") || PRODUCTION_URL
123
+ end
124
+ end
122
125
  end
123
126
  end
124
127
  end
@@ -132,7 +132,7 @@ module Callstacking
132
132
  path, original_url, request_id, headers,
133
133
  params)
134
134
 
135
- puts "#{settings[:url] || Callstacking::Rails::Settings::PRODUCTION_URL}/traces/#{trace_id}"
135
+ print_trace_url(trace_id)
136
136
 
137
137
  create_message(start_request_message(method, controller, action, format),
138
138
  spans.increment_order_num, @traces)
@@ -140,6 +140,16 @@ module Callstacking
140
140
  return trace_id, max_trace_entries
141
141
  end
142
142
 
143
+ def print_trace_url(trace_id)
144
+ url = "#{settings[:url]}/traces/#{trace_id}"
145
+
146
+ puts "*" * url.size
147
+ puts url
148
+ puts "*" * url.size
149
+
150
+ url
151
+ end
152
+
143
153
  def complete_request(method, controller, action, format, original_url, trace_id, traces, max_trace_entries)
144
154
  if do_not_track_request?(original_url, format)
145
155
  traces.clear
@@ -157,9 +167,9 @@ module Callstacking
157
167
  end
158
168
 
159
169
  def do_not_track_request?(url, format)
160
- return false if format =~ /(html|json)/i
161
-
162
- url =~ /(\/stylesheets\/|\/javascripts\/|\/css\/|\/js\/|\.js|\.css)/i
170
+ return true if format == "*/*"
171
+
172
+ (url =~ /(\/assets\/|\/stylesheets\/|\/javascripts\/|\/css\/|\/js\/|\.js|\.css)/i).present?
163
173
  end
164
174
 
165
175
  def return_value(return_val)
@@ -1,5 +1,5 @@
1
1
  module Callstacking
2
2
  module Rails
3
- VERSION = "0.1.17"
3
+ VERSION = "0.1.18"
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.17
4
+ version: 0.1.18
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-02-10 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails