callstacking-rails 0.1.23 → 0.1.25
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 +4 -4
- data/lib/callstacking/rails/client/base.rb +28 -5
- data/lib/callstacking/rails/client/trace.rb +23 -21
- data/lib/callstacking/rails/instrument.rb +3 -0
- data/lib/callstacking/rails/trace.rb +2 -2
- data/lib/callstacking/rails/traces_helper.rb +1 -0
- data/lib/callstacking/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fafc57fcb944f390ece43b46e6417ea090df73c38aee4f6b7362d3bb2492dfc7
|
4
|
+
data.tar.gz: 24344416d9261f55438b4c3848a534cfd329a1ac348ad388ee87144e78a565f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86f2ccc8cc035fe6d955793fa420ad577fcf3613e3f5e847fbb73e4c6a81e144678f5c4b6b8df64074440fa2382ce88c92926da95d0f5d50433fbd9a788e7420
|
7
|
+
data.tar.gz: 7693b49d937092edd0c91ba8865949cf1f29404634aa530e9523a86a84dfb5f17db3582cd84e691045eae0de6ddd0287900c674c47e1e8a21e72f34c48ca187c
|
@@ -7,11 +7,15 @@ module Callstacking
|
|
7
7
|
class Error < StandardError; end
|
8
8
|
|
9
9
|
class Base
|
10
|
+
attr_accessor :async, :threads
|
10
11
|
attr_reader :url, :auth_token
|
11
12
|
|
12
13
|
def initialize(url, auth_token)
|
13
14
|
@url = url
|
14
15
|
@auth_token = auth_token
|
16
|
+
|
17
|
+
@threads = []
|
18
|
+
@async = false
|
15
19
|
end
|
16
20
|
def connection
|
17
21
|
# https://github.com/lostisland/awesome-faraday
|
@@ -23,6 +27,7 @@ module Callstacking
|
|
23
27
|
c.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
|
24
28
|
c.request :json # This will set the "Content-Type" header to application/json and call .to_json on the body
|
25
29
|
c.adapter Faraday.default_adapter
|
30
|
+
c.options.timeout = 5
|
26
31
|
|
27
32
|
if auth_token.present?
|
28
33
|
c.request :authorization, :Bearer, auth_token
|
@@ -31,7 +36,15 @@ module Callstacking
|
|
31
36
|
end
|
32
37
|
|
33
38
|
def get(url, params = {})
|
34
|
-
|
39
|
+
if async
|
40
|
+
threads << Thread.new do
|
41
|
+
connection.get(url, params, headers)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
connection.get(url, params, headers)
|
45
|
+
end
|
46
|
+
ensure
|
47
|
+
Faraday.default_connection.close if async
|
35
48
|
end
|
36
49
|
|
37
50
|
def post(url, params = {}, body = {}, headers_ext = {})
|
@@ -43,12 +56,22 @@ module Callstacking
|
|
43
56
|
end
|
44
57
|
|
45
58
|
def r(action, url, params = {}, body = {}, _headers_ext = {})
|
46
|
-
|
47
|
-
|
48
|
-
|
59
|
+
if async
|
60
|
+
threads << Thread.new do
|
61
|
+
connection.send(action, url) do |req|
|
62
|
+
req.params.merge!(params)
|
63
|
+
req.body = body
|
64
|
+
end
|
65
|
+
end
|
66
|
+
else
|
67
|
+
connection.send(action, url) do |req|
|
68
|
+
req.params.merge!(params)
|
69
|
+
req.body = body
|
70
|
+
end
|
49
71
|
end
|
72
|
+
ensure
|
73
|
+
Faraday.default_connection.close if async
|
50
74
|
end
|
51
|
-
|
52
75
|
end
|
53
76
|
end
|
54
77
|
end
|
@@ -7,33 +7,35 @@ module Callstacking
|
|
7
7
|
CREATE_URL = "/api/v1/traces.json"
|
8
8
|
UPDATE_URL = "/api/v1/traces/:id.json"
|
9
9
|
|
10
|
-
def
|
11
|
-
|
12
|
-
{},
|
13
|
-
{
|
14
|
-
request_id: request_id,
|
15
|
-
tuid: tuid,
|
16
|
-
method_name: method_name,
|
17
|
-
klass: klass,
|
18
|
-
action_name: action_name,
|
19
|
-
format_name: format_name,
|
20
|
-
root_path: root_path,
|
21
|
-
url: url,
|
22
|
-
h: headers.to_h,
|
23
|
-
p: params.to_h,
|
24
|
-
})
|
10
|
+
def initialize(url, auth_token)
|
11
|
+
super
|
25
12
|
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
# All requests for trace and trace entry creation are async
|
14
|
+
# join by the client side generated tuid
|
15
|
+
@async = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(request_id, tuid, method_name, klass, action_name, format_name, root_path, url, headers, params)
|
19
|
+
post(CREATE_URL,
|
20
|
+
{},
|
21
|
+
{
|
22
|
+
request_id: request_id,
|
23
|
+
tuid: tuid,
|
24
|
+
method_name: method_name,
|
25
|
+
klass: klass,
|
26
|
+
action_name: action_name,
|
27
|
+
format_name: format_name,
|
28
|
+
root_path: root_path,
|
29
|
+
url: url,
|
30
|
+
h: headers.to_h,
|
31
|
+
p: params.to_h,
|
32
|
+
})
|
29
33
|
|
30
34
|
nil
|
31
35
|
end
|
32
36
|
|
33
37
|
def upsert(trace_id, traces)
|
34
|
-
|
35
|
-
|
36
|
-
resp.status
|
38
|
+
patch(UPDATE_URL.gsub(':id', trace_id), {}, traces)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -17,6 +17,9 @@ module Callstacking
|
|
17
17
|
method_path = (klass.instance_method(method_name).source_location.first rescue nil) ||
|
18
18
|
(klass.method(method_name).source_location.first rescue nil)
|
19
19
|
|
20
|
+
# method was not defined in Ruby (i.e. native)
|
21
|
+
return if method_path.nil?
|
22
|
+
|
20
23
|
# Application level method definitions
|
21
24
|
return if application_level && !(method_path =~ /#{::Rails.root.to_s}/)
|
22
25
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "rails"
|
2
|
-
require
|
2
|
+
require 'active_support/core_ext/object/deep_dup'
|
3
3
|
|
4
4
|
module Callstacking
|
5
5
|
module Rails
|
@@ -137,7 +137,7 @@ module Callstacking
|
|
137
137
|
return if traces.empty?
|
138
138
|
|
139
139
|
client.upsert(trace_id,
|
140
|
-
{ trace_entries: traces })
|
140
|
+
{ trace_entries: traces.deep_dup })
|
141
141
|
traces.clear
|
142
142
|
end
|
143
143
|
end
|
@@ -32,6 +32,7 @@ module Callstacking
|
|
32
32
|
if (e.ctrlKey && e.which == 68) {
|
33
33
|
if (document.getElementById("callstacking-debugger").style.display === "none") {
|
34
34
|
document.getElementById("callstacking-debugger").style.display = "block";
|
35
|
+
document.getElementById("callstacking-debugger").contentDocument.location.reload(true);
|
35
36
|
document.getElementById("callstacking-debugger").focus();
|
36
37
|
} else {
|
37
38
|
document.getElementById("callstacking-debugger").style.display = "none";
|
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.
|
4
|
+
version: 0.1.25
|
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-04-
|
11
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|