tracebin 0.0.9 → 0.0.10
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/tracebin/events.rb +30 -1
- data/lib/tracebin/middleware.rb +25 -13
- data/lib/tracebin/patches/action_view_layout.rb +6 -2
- data/lib/tracebin/reporter.rb +5 -1
- data/lib/tracebin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d94ffa099d279c476c327437396669eaa91e0f46
|
4
|
+
data.tar.gz: af463513780cde0a9f5b15c16f6ad81946485733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb95a49c5155ce797593b1d49e7067ef0bd87add0c573787f78a123aa77f77a0356907794eee4930a60cb5927d80822e243d5f5fb8b1948bff265b3c7b6a66e9
|
7
|
+
data.tar.gz: 789d333045a7620c5e7858f3ef4fcc1771da2956bbf1c2dd766c61b4662925e9d228c1df95a115cece2d2ef155f5887b44616eb795e0bab2321c5a33031e471b
|
data/lib/tracebin/events.rb
CHANGED
@@ -24,7 +24,7 @@ module Tracebin
|
|
24
24
|
start: event[1],
|
25
25
|
stop: event[2],
|
26
26
|
duration: to_milliseconds(event[2] - event[1]),
|
27
|
-
data: event.last
|
27
|
+
data: select_data || event.last
|
28
28
|
}
|
29
29
|
end
|
30
30
|
end
|
@@ -39,6 +39,14 @@ module Tracebin
|
|
39
39
|
def type
|
40
40
|
:sql
|
41
41
|
end
|
42
|
+
|
43
|
+
def select_data
|
44
|
+
{
|
45
|
+
sql: event.last[:sql],
|
46
|
+
name: event.last[:name],
|
47
|
+
statement_name: event.last[:statement_name]
|
48
|
+
}
|
49
|
+
end
|
42
50
|
end
|
43
51
|
|
44
52
|
class ControllerEvent < Event
|
@@ -47,6 +55,19 @@ module Tracebin
|
|
47
55
|
def type
|
48
56
|
:controller_action
|
49
57
|
end
|
58
|
+
|
59
|
+
def select_data
|
60
|
+
{
|
61
|
+
controller: event.last[:controller],
|
62
|
+
action: event.last[:action],
|
63
|
+
format: event.last[:format],
|
64
|
+
method: event.last[:method],
|
65
|
+
path: event.last[:path],
|
66
|
+
status: event.last[:status],
|
67
|
+
view_runtime: event.last[:view_runtime],
|
68
|
+
db_runtime: event.last[:db_runtime]
|
69
|
+
}
|
70
|
+
end
|
50
71
|
end
|
51
72
|
|
52
73
|
class ViewEvent < Event
|
@@ -55,6 +76,10 @@ module Tracebin
|
|
55
76
|
def type
|
56
77
|
:view
|
57
78
|
end
|
79
|
+
|
80
|
+
def select_data
|
81
|
+
nil
|
82
|
+
end
|
58
83
|
end
|
59
84
|
|
60
85
|
class SinatraEvent < Event
|
@@ -63,5 +88,9 @@ module Tracebin
|
|
63
88
|
def type
|
64
89
|
:route
|
65
90
|
end
|
91
|
+
|
92
|
+
def select_data
|
93
|
+
nil
|
94
|
+
end
|
66
95
|
end
|
67
96
|
end
|
data/lib/tracebin/middleware.rb
CHANGED
@@ -3,13 +3,14 @@ require 'tracebin/puppet_master'
|
|
3
3
|
|
4
4
|
module Tracebin
|
5
5
|
class Middleware
|
6
|
-
attr_reader :config
|
6
|
+
attr_reader :config, :logger
|
7
7
|
|
8
8
|
def initialize(app)
|
9
9
|
@app = app
|
10
10
|
@config = Tracebin::Agent.config
|
11
|
+
@logger = Tracebin::Agent.logger
|
11
12
|
|
12
|
-
|
13
|
+
start_agent
|
13
14
|
end
|
14
15
|
|
15
16
|
def call(env)
|
@@ -17,24 +18,21 @@ module Tracebin
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def __call(env)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if ignored_paths.any? { |root| !!root.match(path) }
|
24
|
-
@app.call env
|
21
|
+
if agent_disabled?(env)
|
22
|
+
return @app.call env
|
25
23
|
else
|
26
|
-
|
27
|
-
|
24
|
+
@tracebin_timer = Timer.new
|
25
|
+
@tracebin_timer.start!
|
28
26
|
|
29
27
|
status, headers, response = @app.call(env)
|
30
28
|
|
31
|
-
|
29
|
+
@tracebin_timer.transaction_name = fetch_endpoint_name(env)
|
32
30
|
|
33
|
-
|
31
|
+
@tracebin_timer.stop!
|
34
32
|
|
35
|
-
PuppetMaster.new(
|
33
|
+
PuppetMaster.new(@tracebin_timer).process
|
36
34
|
|
37
|
-
[status, headers, response]
|
35
|
+
return [status, headers, response]
|
38
36
|
end
|
39
37
|
end
|
40
38
|
|
@@ -47,5 +45,19 @@ module Tracebin
|
|
47
45
|
'RackTransaction'
|
48
46
|
end
|
49
47
|
end
|
48
|
+
|
49
|
+
def start_agent
|
50
|
+
Tracebin::Agent.start!
|
51
|
+
rescue => e
|
52
|
+
@logger.warn "TRACEBIN: Failed to start agent: #{e.message}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def agent_disabled?(env)
|
56
|
+
path = env['REQUEST_PATH']
|
57
|
+
ignored_paths = config.ignored_paths.map { |root| %r{^#{root}} }
|
58
|
+
|
59
|
+
!Tracebin::Agent.started? ||
|
60
|
+
ignored_paths.any? { |root| !!root.match(path) }
|
61
|
+
end
|
50
62
|
end
|
51
63
|
end
|
@@ -14,8 +14,10 @@
|
|
14
14
|
|
15
15
|
if layout
|
16
16
|
start_time = Time.now
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
result = render_with_layout_without_tracebin(path, locals, *args, &block)
|
19
|
+
|
20
|
+
end_time = Time.now
|
19
21
|
|
20
22
|
event_data = [
|
21
23
|
'render_layout.action_view',
|
@@ -27,6 +29,8 @@
|
|
27
29
|
]
|
28
30
|
|
29
31
|
::Tracebin::Patches.handle_event :action_view_layout, event_data
|
32
|
+
|
33
|
+
result
|
30
34
|
else
|
31
35
|
render_with_layout_without_tracebin(path, locals, *args, &block)
|
32
36
|
end
|
data/lib/tracebin/reporter.rb
CHANGED
@@ -62,6 +62,7 @@ module Tracebin
|
|
62
62
|
res
|
63
63
|
rescue Exception => e
|
64
64
|
logger.warn "TRACEBIN: Exception occurred sending data to the server: #{e.message}"
|
65
|
+
logger.debug "TRACEBIN: #{e.backtrace.join("\n\t")}"
|
65
66
|
Tracebin::Agent.stop!
|
66
67
|
end
|
67
68
|
|
@@ -69,9 +70,12 @@ module Tracebin
|
|
69
70
|
case res
|
70
71
|
when Net::HTTPSuccess
|
71
72
|
logger.info 'TRACEBIN: Successfully sent payload to the server.'
|
72
|
-
when Net::
|
73
|
+
when Net::HTTPNotFound
|
73
74
|
logger.warn 'TRACEBIN: App bin ID not found. Please create a new app bin and add it to the config.'
|
74
75
|
Tracebin::Agent.stop!
|
76
|
+
when Net::HTTPBadRequest
|
77
|
+
logger.warn 'Something went wrong with the server. Please contact us!'
|
78
|
+
Tracebin::Agent.stop!
|
75
79
|
else
|
76
80
|
logger.warn 'TRACEBIN: Failed to send data to the server. Will try again in 1 minute.'
|
77
81
|
@storage.add_payload payload
|
data/lib/tracebin/version.rb
CHANGED