app_perf_rpm 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app_perf_rpm.rb +1 -1
- data/lib/app_perf_rpm/backtrace.rb +27 -10
- data/lib/app_perf_rpm/configuration.rb +13 -13
- data/lib/app_perf_rpm/instruments/action_controller.rb +2 -4
- data/lib/app_perf_rpm/instruments/action_view.rb +5 -10
- data/lib/app_perf_rpm/instruments/active_record/adapters/mysql2.rb +1 -2
- data/lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb +4 -8
- data/lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb +4 -8
- data/lib/app_perf_rpm/instruments/activerecord_import.rb +1 -2
- data/lib/app_perf_rpm/instruments/emque_consuming.rb +1 -2
- data/lib/app_perf_rpm/instruments/faraday.rb +1 -2
- data/lib/app_perf_rpm/instruments/net_http.rb +1 -2
- data/lib/app_perf_rpm/instruments/rack.rb +2 -3
- data/lib/app_perf_rpm/instruments/redis.rb +2 -4
- data/lib/app_perf_rpm/instruments/sequel.rb +2 -4
- data/lib/app_perf_rpm/instruments/sidekiq.rb +2 -4
- data/lib/app_perf_rpm/instruments/sinatra.rb +2 -4
- data/lib/app_perf_rpm/instruments/typhoeus.rb +2 -4
- data/lib/app_perf_rpm/reporters/json_client.rb +1 -2
- data/lib/app_perf_rpm/tracer.rb +2 -2
- data/lib/app_perf_rpm/tracing/span.rb +1 -1
- data/lib/app_perf_rpm/utils.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 287c60f79f2d95e971bc6c92a0d5d364e347ec65
|
4
|
+
data.tar.gz: 5d161a6e804aad795dc1754eeb6368f6e2e2b37c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 029aeda66471dc5592f6446a4bdd859d7d40adb68f7e8e597a66ec986d01689f47a4ca78cf89365968f3cc3a810132a0f7a47dd41dcc5e7c97282766d7d5be8f
|
7
|
+
data.tar.gz: b0f1a56fcb522c5bd65e637de52bb57f934a2f15a522227ce97431d629f9c98bac1234cc1a4105a642485ec08ddc7dc67ab3f691a67da4364d0cb5c28cb9790a
|
data/lib/app_perf_rpm.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module AppPerfRpm
|
2
2
|
class Backtrace
|
3
3
|
class << self
|
4
|
-
def backtrace
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
def backtrace(kind: :all)
|
5
|
+
if kind
|
6
|
+
bt = Kernel.caller
|
7
|
+
bt = clean(bt)
|
8
|
+
bt = filter(bt, kind)
|
9
|
+
trim_backtrace(bt)
|
10
|
+
end
|
8
11
|
end
|
9
12
|
|
10
13
|
def clean(backtrace)
|
@@ -13,6 +16,19 @@ module AppPerfRpm
|
|
13
16
|
.select {|b| b !~ %r{lib/app_perf_rpm} }
|
14
17
|
end
|
15
18
|
|
19
|
+
def filter(backtrace, kind)
|
20
|
+
case kind
|
21
|
+
when :all
|
22
|
+
backtrace
|
23
|
+
when :app
|
24
|
+
backtrace.select {|b| b =~ /\[APP_PATH\]/ }
|
25
|
+
when :gem
|
26
|
+
backtrace.select {|b| b =~ /\[GEM_PATH\]/ }
|
27
|
+
else
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
16
32
|
#def source_extract(_backtrace = Kernel.caller(2))
|
17
33
|
# if(trace = _backtrace.first)
|
18
34
|
# file, line_number = extract_file_and_line_number(trace)
|
@@ -26,8 +42,8 @@ module AppPerfRpm
|
|
26
42
|
# end
|
27
43
|
#end
|
28
44
|
|
29
|
-
def source_extract(
|
30
|
-
Array(
|
45
|
+
def source_extract(backtrace: Kernel.caller(0))
|
46
|
+
Array(backtrace).select {|bt| bt[/^#{::AppPerfRpm.config.app_root.to_s}\//] }.map do |trace|
|
31
47
|
file, line_number = extract_file_and_line_number(trace)
|
32
48
|
source_to_hash(file, line_number)
|
33
49
|
end
|
@@ -75,13 +91,14 @@ module AppPerfRpm
|
|
75
91
|
[file, line.to_i]
|
76
92
|
end
|
77
93
|
|
78
|
-
def trim_backtrace(_backtrace)
|
94
|
+
def trim_backtrace(_backtrace, kind: :all)
|
79
95
|
return _backtrace unless _backtrace.is_a?(Array)
|
80
96
|
|
81
97
|
length = _backtrace.size
|
82
|
-
if length >
|
83
|
-
|
84
|
-
trimmed
|
98
|
+
if length > 80
|
99
|
+
trimmed = _backtrace[0, 80]
|
100
|
+
trimmed += ['...[snip]...']
|
101
|
+
trimmed += _backtrace[length - 20, 20]
|
85
102
|
else
|
86
103
|
trimmed = _backtrace
|
87
104
|
end
|
@@ -32,19 +32,19 @@ module AppPerfRpm
|
|
32
32
|
self.agent_disabled ||= default_if_blank(ENV["APP_PERF_AGENT_DISABLED"], false)
|
33
33
|
self.ignore_paths ||= /\/assets/
|
34
34
|
self.instrumentation = {
|
35
|
-
:rack => { :enabled => true, :backtrace =>
|
36
|
-
:active_record => { :enabled => true, :backtrace =>
|
37
|
-
:active_record_import => { :enabled => true, :backtrace =>
|
38
|
-
:action_view => { :enabled => true, :backtrace =>
|
39
|
-
:action_controller => { :enabled => true, :backtrace =>
|
40
|
-
:emque_consuming => { :enabled => true, :backtrace =>
|
41
|
-
:redis => { :enabled => true, :backtrace =>
|
42
|
-
:sequel => { :enabled => true, :backtrace =>
|
43
|
-
:sidekiq => { :enabled => true, :backtrace =>
|
44
|
-
:sinatra => { :enabled => true, :backtrace =>
|
45
|
-
:net_http => { :enabled => true, :backtrace =>
|
46
|
-
:typhoeus => { :enabled => true, :backtrace =>
|
47
|
-
:faraday => { :enabled => true, :backtrace =>
|
35
|
+
:rack => { :enabled => true, :backtrace => :app, :source => true, :trace_middleware => false },
|
36
|
+
:active_record => { :enabled => true, :backtrace => :app, :source => true },
|
37
|
+
:active_record_import => { :enabled => true, :backtrace => :app, :source => true },
|
38
|
+
:action_view => { :enabled => true, :backtrace => :app, :source => true },
|
39
|
+
:action_controller => { :enabled => true, :backtrace => :app, :source => true },
|
40
|
+
:emque_consuming => { :enabled => true, :backtrace => :app, :source => true },
|
41
|
+
:redis => { :enabled => true, :backtrace => :app, :source => true },
|
42
|
+
:sequel => { :enabled => true, :backtrace => :app, :source => true },
|
43
|
+
:sidekiq => { :enabled => true, :backtrace => :app, :source => true },
|
44
|
+
:sinatra => { :enabled => true, :backtrace => :app, :source => true },
|
45
|
+
:net_http => { :enabled => true, :backtrace => :app, :source => true },
|
46
|
+
:typhoeus => { :enabled => true, :backtrace => :app, :source => true },
|
47
|
+
:faraday => { :enabled => true, :backtrace => :app, :source => true }
|
48
48
|
}
|
49
49
|
end
|
50
50
|
end
|
@@ -8,8 +8,7 @@ module AppPerfRpm
|
|
8
8
|
"component" => "ActionController",
|
9
9
|
"span.kind" => "client"
|
10
10
|
})
|
11
|
-
|
12
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
11
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_controller)
|
13
12
|
end
|
14
13
|
|
15
14
|
process_action_without_trace(method_name, *args)
|
@@ -30,8 +29,7 @@ module AppPerfRpm
|
|
30
29
|
"component" => "ActionController",
|
31
30
|
"span.kind" => "client"
|
32
31
|
})
|
33
|
-
|
34
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
32
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_controller)
|
35
33
|
end
|
36
34
|
perform_action_without_trace(*arguments)
|
37
35
|
rescue Exception => e
|
@@ -11,8 +11,7 @@ if ::AppPerfRpm.config.instrumentation[:action_view][:enabled] && defined?(::Act
|
|
11
11
|
"view.action" => @_request.path_parameters['action'],
|
12
12
|
"view.template" => options[:partial]
|
13
13
|
})
|
14
|
-
|
15
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
14
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_view)
|
16
15
|
end
|
17
16
|
|
18
17
|
render_partial_without_trace(options)
|
@@ -36,8 +35,7 @@ if ::AppPerfRpm.config.instrumentation[:action_view][:enabled] && defined?(::Act
|
|
36
35
|
"view.action" => @_request.path_parameters['action'],
|
37
36
|
"view.template" => @path
|
38
37
|
})
|
39
|
-
|
40
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
38
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_view)
|
41
39
|
end
|
42
40
|
|
43
41
|
render_partial_collection_without_trace(options)
|
@@ -61,8 +59,7 @@ if ::AppPerfRpm.config.instrumentation[:action_view][:enabled] && defined?(::Act
|
|
61
59
|
"span.kind" => "client",
|
62
60
|
"view.template" => @options[:partial]
|
63
61
|
})
|
64
|
-
|
65
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
62
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_view)
|
66
63
|
end
|
67
64
|
|
68
65
|
render_partial_without_trace
|
@@ -86,8 +83,7 @@ if ::AppPerfRpm.config.instrumentation[:action_view][:enabled] && defined?(::Act
|
|
86
83
|
"view.action" => @_request.path_parameters['action'],
|
87
84
|
"view.template" => @path
|
88
85
|
})
|
89
|
-
|
90
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
86
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_view)
|
91
87
|
end
|
92
88
|
|
93
89
|
render_collection_without_trace
|
@@ -133,8 +129,7 @@ if ::AppPerfRpm.config.instrumentation[:action_view][:enabled] && defined?(::Act
|
|
133
129
|
end
|
134
130
|
span.set_tag "component", "ActionView"
|
135
131
|
span.set_tag "span.kind", "client"
|
136
|
-
|
137
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
132
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :action_view)
|
138
133
|
end
|
139
134
|
|
140
135
|
render_with_layout_without_trace(path, locals, *args, &block)
|
@@ -32,8 +32,7 @@ module AppPerfRpm
|
|
32
32
|
"db.vendor" => adapter,
|
33
33
|
"db.type" => "sql"
|
34
34
|
})
|
35
|
-
|
36
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
35
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -32,8 +32,7 @@ module AppPerfRpm
|
|
32
32
|
"db.vendor" => adapter,
|
33
33
|
"db.type" => "sql"
|
34
34
|
})
|
35
|
-
|
36
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
35
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -63,8 +62,7 @@ module AppPerfRpm
|
|
63
62
|
"db.vendor" => adapter,
|
64
63
|
"db.type" => "sql"
|
65
64
|
})
|
66
|
-
|
67
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
65
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -94,8 +92,7 @@ module AppPerfRpm
|
|
94
92
|
"db.vendor" => adapter,
|
95
93
|
"db.type" => "sql"
|
96
94
|
})
|
97
|
-
|
98
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
95
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
99
96
|
end
|
100
97
|
end
|
101
98
|
|
@@ -124,8 +121,7 @@ module AppPerfRpm
|
|
124
121
|
"db.vendor" => adapter,
|
125
122
|
"db.type" => "sql"
|
126
123
|
})
|
127
|
-
|
128
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
124
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
129
125
|
end
|
130
126
|
|
131
127
|
begin_db_transaction_without_trace
|
@@ -32,8 +32,7 @@ module AppPerfRpm
|
|
32
32
|
"db.vendor" => adapter,
|
33
33
|
"db.type" => "sql"
|
34
34
|
})
|
35
|
-
|
36
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
35
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -63,8 +62,7 @@ module AppPerfRpm
|
|
63
62
|
"db.vendor" => adapter,
|
64
63
|
"db.type" => "sql"
|
65
64
|
})
|
66
|
-
|
67
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
65
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -94,8 +92,7 @@ module AppPerfRpm
|
|
94
92
|
"db.vendor" => adapter,
|
95
93
|
"db.type" => "sql"
|
96
94
|
})
|
97
|
-
|
98
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
95
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
99
96
|
end
|
100
97
|
end
|
101
98
|
|
@@ -123,8 +120,7 @@ module AppPerfRpm
|
|
123
120
|
"db.vendor" => adapter,
|
124
121
|
"db.type" => "sql"
|
125
122
|
})
|
126
|
-
|
127
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
123
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record)
|
128
124
|
end
|
129
125
|
|
130
126
|
begin_db_transaction_without_trace
|
@@ -24,8 +24,7 @@ module AppPerfRpm
|
|
24
24
|
"db.vendor" => adapter,
|
25
25
|
"db.type" => "sql"
|
26
26
|
})
|
27
|
-
|
28
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
27
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :active_record_import)
|
29
28
|
end
|
30
29
|
|
31
30
|
insert_many_without_trace(sql, values, *args)
|
@@ -10,8 +10,7 @@ module AppPerfRpm
|
|
10
10
|
"http.url" => "/#{topic}/#{action}",
|
11
11
|
"peer.address" => Socket.gethostname
|
12
12
|
})
|
13
|
-
|
14
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
13
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :emque_consuming)
|
15
14
|
|
16
15
|
route_without_trace(topic, type, message)
|
17
16
|
rescue Exception => e
|
@@ -16,8 +16,7 @@ module AppPerfRpm
|
|
16
16
|
span.set_tag "http.url", url
|
17
17
|
span.set_tag "http.method", method
|
18
18
|
span.set_tag "http.status_code", result.status
|
19
|
-
|
20
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
19
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :faraday)
|
21
20
|
span.finish
|
22
21
|
else
|
23
22
|
result = run_request_without_trace(method, url, body, headers, &block)
|
@@ -16,8 +16,7 @@ if ::AppPerfRpm.config.instrumentation[:net_http][:enabled] && defined?(Net::HTT
|
|
16
16
|
span.set_tag "http.url", req.path
|
17
17
|
span.set_tag "http.method", req.method
|
18
18
|
span.set_tag "peer.hostname", addr_port
|
19
|
-
|
20
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
19
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :net_http)
|
21
20
|
end
|
22
21
|
|
23
22
|
response = request_without_trace(*args, &block)
|
@@ -60,15 +60,14 @@ if ::AppPerfRpm.config.instrumentation[:rack][:enabled]
|
|
60
60
|
|
61
61
|
unless ignore_path?(req.path)
|
62
62
|
extracted_ctx = AppPerfRpm.tracer.extract(OpenTracing::FORMAT_RACK, env)
|
63
|
-
AppPerfRpm::Tracer.sample!(extracted_ctx)
|
63
|
+
AppPerfRpm::Tracer.sample!(extracted_ctx, !!req.params["app-perf-sample"])
|
64
64
|
|
65
65
|
if AppPerfRpm::Tracer.tracing?
|
66
66
|
span = AppPerfRpm.tracer.start_span(@app.class.name, :child_of => extracted_ctx, tags: {
|
67
67
|
"component" => "Rack",
|
68
68
|
"span.kind" => "client"
|
69
69
|
})
|
70
|
-
|
71
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
70
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :rack)
|
72
71
|
end
|
73
72
|
end
|
74
73
|
|
@@ -15,8 +15,7 @@ module AppPerf
|
|
15
15
|
"db.instance" => self.db,
|
16
16
|
"db.statement" => format_redis_command(*command)
|
17
17
|
})
|
18
|
-
|
19
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
18
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :redis)
|
20
19
|
end
|
21
20
|
|
22
21
|
call_without_trace(*command, &block)
|
@@ -42,8 +41,7 @@ module AppPerf
|
|
42
41
|
"db.instance" => self.db,
|
43
42
|
"db.statement" => pipeline[0].commands.map { |c| format_redis_command(c) }.join("\n")
|
44
43
|
})
|
45
|
-
|
46
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
44
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :redis)
|
47
45
|
end
|
48
46
|
|
49
47
|
call_pipeline_without_trace(*pipeline)
|
@@ -40,8 +40,7 @@ module AppPerfRpm
|
|
40
40
|
span = ::AppPerfRpm.tracer.start_span("sequel", tags: parse_opts(sql, options))
|
41
41
|
span.set_tag "component", "Sequel"
|
42
42
|
span.set_tag "span.kind", "client"
|
43
|
-
|
44
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
43
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sequel)
|
45
44
|
end
|
46
45
|
|
47
46
|
run_without_trace(sql, options)
|
@@ -64,8 +63,7 @@ module AppPerfRpm
|
|
64
63
|
span = ::AppPerfRpm.tracer.start_span("sequel", tags: parse_opts(sql, options))
|
65
64
|
span.set_tag "component", "Sequel"
|
66
65
|
span.set_tag "span.kind", "client"
|
67
|
-
|
68
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
66
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sequel)
|
69
67
|
end
|
70
68
|
|
71
69
|
execute_without_trace(sql, options, &block)
|
@@ -16,8 +16,7 @@ module AppPerfRpm
|
|
16
16
|
"bg.queue" => queue,
|
17
17
|
"bg.job_name" => worker.class.to_s
|
18
18
|
})
|
19
|
-
|
20
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
19
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sidekiq)
|
21
20
|
end
|
22
21
|
|
23
22
|
yield
|
@@ -54,8 +53,7 @@ module AppPerfRpm
|
|
54
53
|
"bg.queue" => queue,
|
55
54
|
"bg.job_name" => worker.class.to_s
|
56
55
|
})
|
57
|
-
|
58
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
56
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sidekiq)
|
59
57
|
|
60
58
|
inject(span, msg)
|
61
59
|
end
|
@@ -8,8 +8,7 @@ module AppPerfRpm
|
|
8
8
|
span = ::AppPerfRpm.tracer.start_span(operation, tags: {
|
9
9
|
component: "Sinatra"
|
10
10
|
})
|
11
|
-
|
12
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
11
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sinatra)
|
13
12
|
end
|
14
13
|
|
15
14
|
dispatch_without_trace
|
@@ -40,8 +39,7 @@ module AppPerfRpm
|
|
40
39
|
"view.line_number" => __LINE__,
|
41
40
|
"view.template" => __FILE__
|
42
41
|
})
|
43
|
-
|
44
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
42
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :sinatra)
|
45
43
|
end
|
46
44
|
|
47
45
|
render_without_trace(engine, data, options, locals, &block)
|
@@ -15,8 +15,7 @@ module AppPerfRpm
|
|
15
15
|
span.set_tag "http.status_code", response.code
|
16
16
|
span.set_tag "http.url", uri.to_s
|
17
17
|
span.set_tag "http.method", options[:method]
|
18
|
-
|
19
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
18
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :typhoeus)
|
20
19
|
else
|
21
20
|
response = run_without_trace
|
22
21
|
end
|
@@ -40,8 +39,7 @@ module AppPerfRpm
|
|
40
39
|
"http.queued_requests" => queued_requests.count,
|
41
40
|
"http.max_concurrency" => max_concurrency
|
42
41
|
})
|
43
|
-
|
44
|
-
span.log(event: "source", stack: ::AppPerfRpm::Backtrace.source_extract)
|
42
|
+
AppPerfRpm::Utils.log_source_and_backtrace(span, :typhoeus)
|
45
43
|
|
46
44
|
run_without_trace
|
47
45
|
rescue Exception => e
|
@@ -29,7 +29,7 @@ module AppPerfRpm
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def compress_body(data)
|
32
|
-
body =
|
32
|
+
body = MessagePack.pack({
|
33
33
|
"name" => AppPerfRpm.config.application_name,
|
34
34
|
"host" => AppPerfRpm.host,
|
35
35
|
"data" => data
|
@@ -46,7 +46,6 @@ module AppPerfRpm
|
|
46
46
|
sock.use_ssl = ::AppPerfRpm.config.ssl
|
47
47
|
|
48
48
|
request = Net::HTTP::Post.new(@spans_uri.request_uri, {
|
49
|
-
'Content-Type' => 'application/json',
|
50
49
|
"Accept-Encoding" => "gzip",
|
51
50
|
"User-Agent" => "gzip"
|
52
51
|
})
|
data/lib/app_perf_rpm/tracer.rb
CHANGED
@@ -6,7 +6,7 @@ module AppPerfRpm
|
|
6
6
|
# This method should be called by any components that are
|
7
7
|
# capable of starting the tracing process.
|
8
8
|
# ie. rack, sidekiq worker, etc
|
9
|
-
def sample!(incoming_trace = nil)
|
9
|
+
def sample!(incoming_trace = nil, force = false)
|
10
10
|
# Since we keep track of the active span, meaning we have entered into
|
11
11
|
# tracing at some point, and we no longer have an active span,
|
12
12
|
# reset tracing.
|
@@ -14,7 +14,7 @@ module AppPerfRpm
|
|
14
14
|
|
15
15
|
# Now determine if we want to trace, either by an incoming
|
16
16
|
# trace or meeting the sample rate.
|
17
|
-
Thread.current[:sample] = !!incoming_trace || should_sample?
|
17
|
+
Thread.current[:sample] = force || !!incoming_trace || should_sample?
|
18
18
|
Thread.current[:sample]
|
19
19
|
end
|
20
20
|
|
@@ -51,7 +51,7 @@ module AppPerfRpm
|
|
51
51
|
message: exception.message,
|
52
52
|
error_class: exception.class.to_s,
|
53
53
|
backtrace: AppPerfRpm::Backtrace.clean(exception.backtrace),
|
54
|
-
source: AppPerfRpm::Backtrace.source_extract(exception.backtrace)
|
54
|
+
source: AppPerfRpm::Backtrace.source_extract(backtrace: exception.backtrace)
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
data/lib/app_perf_rpm/utils.rb
CHANGED
@@ -23,5 +23,21 @@ module AppPerfRpm
|
|
23
23
|
def format_redis_command(command)
|
24
24
|
command.map { |x| format_redis(x) }.join(' ')
|
25
25
|
end
|
26
|
+
|
27
|
+
def self.log_source_and_backtrace(span, instrument)
|
28
|
+
config = ::AppPerfRpm.config.instrumentation[instrument] || {}
|
29
|
+
if kind = config[:backtrace]
|
30
|
+
backtrace = AppPerfRpm::Backtrace.backtrace(kind: kind)
|
31
|
+
if backtrace.length > 0
|
32
|
+
span.log(event: "backtrace", stack: backtrace)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if config[:source]
|
36
|
+
source = AppPerfRpm::Backtrace.source_extract
|
37
|
+
if source.length > 0
|
38
|
+
span.log(event: "source", stack: source)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
26
42
|
end
|
27
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app_perf_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Randy Girard
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|