app_perf_rpm 0.0.6 → 0.0.7

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
  SHA1:
3
- metadata.gz: 049ed9d70578f19385c19d57d2a9794be48518a0
4
- data.tar.gz: 5ebeb333e89d38319a413d92f4a7e41f5bd11348
3
+ metadata.gz: 287c60f79f2d95e971bc6c92a0d5d364e347ec65
4
+ data.tar.gz: 5d161a6e804aad795dc1754eeb6368f6e2e2b37c
5
5
  SHA512:
6
- metadata.gz: 50cfe054972dcb5a8ba179383c4ad7433a4a84c13d2c70f73afe6dd1401715e82d8bcecab2311b8e2a737de84507376eb5794b6e4e624ecbfda9c5a3a86ae3f3
7
- data.tar.gz: 9ac2e437821c812c0c345dc61c32067ad35d7dc45c7614ae5f5bf6e1e85a89ee10b13f2c99ec83ecbe58ce4a3dda8c40211bf7901b23e41284d8903b146820f5
6
+ metadata.gz: 029aeda66471dc5592f6446a4bdd859d7d40adb68f7e8e597a66ec986d01689f47a4ca78cf89365968f3cc3a810132a0f7a47dd41dcc5e7c97282766d7d5be8f
7
+ data.tar.gz: b0f1a56fcb522c5bd65e637de52bb57f934a2f15a522227ce97431d629f9c98bac1234cc1a4105a642485ec08ddc7dc67ab3f691a67da4364d0cb5c28cb9790a
data/lib/app_perf_rpm.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'oj'
1
+ require 'msgpack'
2
2
 
3
3
  module AppPerfRpm
4
4
  require 'app_perf_rpm/logger'
@@ -1,10 +1,13 @@
1
1
  module AppPerfRpm
2
2
  class Backtrace
3
3
  class << self
4
- def backtrace
5
- bt = Kernel.caller
6
- bt = clean(bt)
7
- trim_backtrace(bt)
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(_backtrace = Kernel.caller(0))
30
- Array(_backtrace).select {|bt| bt[/^#{::AppPerfRpm.config.app_root.to_s}\//] }.map do |trace|
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 > 100
83
- # Trim backtraces by getting the first 180 and last 20 lines
84
- trimmed = _backtrace[0, 80] + ['...[snip]...'] + _backtrace[length - 20, 20]
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 => false, :trace_middleware => false },
36
- :active_record => { :enabled => true, :backtrace => false },
37
- :active_record_import => { :enabled => true, :backtrace => false },
38
- :action_view => { :enabled => true, :backtrace => false },
39
- :action_controller => { :enabled => true, :backtrace => false },
40
- :emque_consuming => { :enabled => true, :backtrace => false },
41
- :redis => { :enabled => true, :backtrace => false },
42
- :sequel => { :enabled => true, :backtrace => false },
43
- :sidekiq => { :enabled => true, :backtrace => false },
44
- :sinatra => { :enabled => true, :backtrace => false },
45
- :net_http => { :enabled => true, :backtrace => false },
46
- :typhoeus => { :enabled => true, :backtrace => false },
47
- :faraday => { :enabled => true, :backtrace => false }
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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
- span.log(event: "backtrace", stack: ::AppPerfRpm::Backtrace.backtrace)
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 = Oj.dump({
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
  })
@@ -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
 
@@ -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.6
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: oj
14
+ name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="