scout_apm 2.2.0.pre3 → 2.3.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.markdown +147 -2
  4. data/Guardfile +43 -0
  5. data/Rakefile +2 -2
  6. data/ext/allocations/allocations.c +6 -0
  7. data/ext/allocations/extconf.rb +1 -0
  8. data/ext/rusage/README.md +26 -0
  9. data/ext/rusage/extconf.rb +5 -0
  10. data/ext/rusage/rusage.c +52 -0
  11. data/lib/scout_apm.rb +28 -15
  12. data/lib/scout_apm/agent.rb +89 -37
  13. data/lib/scout_apm/agent/logging.rb +6 -1
  14. data/lib/scout_apm/agent/reporting.rb +9 -6
  15. data/lib/scout_apm/app_server_load.rb +21 -10
  16. data/lib/scout_apm/attribute_arranger.rb +6 -3
  17. data/lib/scout_apm/background_job_integrations/delayed_job.rb +71 -1
  18. data/lib/scout_apm/background_job_integrations/resque.rb +85 -0
  19. data/lib/scout_apm/background_job_integrations/sidekiq.rb +22 -20
  20. data/lib/scout_apm/background_recorder.rb +43 -0
  21. data/lib/scout_apm/background_worker.rb +19 -15
  22. data/lib/scout_apm/config.rb +138 -28
  23. data/lib/scout_apm/db_query_metric_set.rb +80 -0
  24. data/lib/scout_apm/db_query_metric_stats.rb +102 -0
  25. data/lib/scout_apm/debug.rb +37 -0
  26. data/lib/scout_apm/environment.rb +22 -15
  27. data/lib/scout_apm/git_revision.rb +51 -0
  28. data/lib/scout_apm/histogram.rb +11 -2
  29. data/lib/scout_apm/instant/assets/xmlhttp_instrumentation.html +2 -2
  30. data/lib/scout_apm/instant/middleware.rb +196 -54
  31. data/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb +89 -68
  32. data/lib/scout_apm/instruments/action_view.rb +49 -0
  33. data/lib/scout_apm/instruments/active_record.rb +127 -3
  34. data/lib/scout_apm/instruments/grape.rb +4 -3
  35. data/lib/scout_apm/instruments/middleware_detailed.rb +4 -6
  36. data/lib/scout_apm/instruments/mongoid.rb +24 -3
  37. data/lib/scout_apm/instruments/net_http.rb +7 -2
  38. data/lib/scout_apm/instruments/percentile_sampler.rb +36 -19
  39. data/lib/scout_apm/instruments/process/process_cpu.rb +3 -2
  40. data/lib/scout_apm/instruments/process/process_memory.rb +3 -3
  41. data/lib/scout_apm/instruments/resque.rb +40 -0
  42. data/lib/scout_apm/layaway.rb +67 -28
  43. data/lib/scout_apm/layer.rb +19 -59
  44. data/lib/scout_apm/layer_children_set.rb +77 -0
  45. data/lib/scout_apm/layer_converters/allocation_metric_converter.rb +5 -6
  46. data/lib/scout_apm/layer_converters/converter_base.rb +201 -14
  47. data/lib/scout_apm/layer_converters/database_converter.rb +55 -0
  48. data/lib/scout_apm/layer_converters/depth_first_walker.rb +22 -10
  49. data/lib/scout_apm/layer_converters/error_converter.rb +5 -7
  50. data/lib/scout_apm/layer_converters/find_layer_by_type.rb +34 -0
  51. data/lib/scout_apm/layer_converters/histograms.rb +14 -0
  52. data/lib/scout_apm/layer_converters/job_converter.rb +36 -50
  53. data/lib/scout_apm/layer_converters/metric_converter.rb +17 -19
  54. data/lib/scout_apm/layer_converters/request_queue_time_converter.rb +10 -12
  55. data/lib/scout_apm/layer_converters/slow_job_converter.rb +41 -115
  56. data/lib/scout_apm/layer_converters/slow_request_converter.rb +33 -117
  57. data/lib/scout_apm/limited_layer.rb +126 -0
  58. data/lib/scout_apm/metric_meta.rb +0 -5
  59. data/lib/scout_apm/metric_set.rb +9 -1
  60. data/lib/scout_apm/metric_stats.rb +7 -8
  61. data/lib/scout_apm/rack.rb +26 -0
  62. data/lib/scout_apm/remote/message.rb +23 -0
  63. data/lib/scout_apm/remote/recorder.rb +57 -0
  64. data/lib/scout_apm/remote/router.rb +49 -0
  65. data/lib/scout_apm/remote/server.rb +58 -0
  66. data/lib/scout_apm/reporter.rb +51 -15
  67. data/lib/scout_apm/request_histograms.rb +4 -0
  68. data/lib/scout_apm/request_manager.rb +2 -1
  69. data/lib/scout_apm/scored_item_set.rb +7 -0
  70. data/lib/scout_apm/serializers/db_query_serializer_to_json.rb +15 -0
  71. data/lib/scout_apm/serializers/histograms_serializer_to_json.rb +21 -0
  72. data/lib/scout_apm/serializers/payload_serializer.rb +10 -3
  73. data/lib/scout_apm/serializers/payload_serializer_to_json.rb +6 -6
  74. data/lib/scout_apm/serializers/slow_jobs_serializer_to_json.rb +2 -1
  75. data/lib/scout_apm/server_integrations/puma.rb +5 -2
  76. data/lib/scout_apm/slow_job_policy.rb +1 -10
  77. data/lib/scout_apm/slow_job_record.rb +6 -1
  78. data/lib/scout_apm/slow_request_policy.rb +1 -10
  79. data/lib/scout_apm/slow_transaction.rb +20 -2
  80. data/lib/scout_apm/store.rb +66 -12
  81. data/lib/scout_apm/synchronous_recorder.rb +26 -0
  82. data/lib/scout_apm/tracked_request.rb +136 -71
  83. data/lib/scout_apm/utils/active_record_metric_name.rb +8 -4
  84. data/lib/scout_apm/utils/backtrace_parser.rb +3 -3
  85. data/lib/scout_apm/utils/gzip_helper.rb +24 -0
  86. data/lib/scout_apm/utils/numbers.rb +14 -0
  87. data/lib/scout_apm/utils/scm.rb +14 -0
  88. data/lib/scout_apm/version.rb +1 -1
  89. data/scout_apm.gemspec +5 -4
  90. data/test/test_helper.rb +18 -0
  91. data/test/unit/config_test.rb +59 -8
  92. data/test/unit/db_query_metric_set_test.rb +56 -0
  93. data/test/unit/db_query_metric_stats_test.rb +113 -0
  94. data/test/unit/git_revision_test.rb +15 -0
  95. data/test/unit/histogram_test.rb +14 -0
  96. data/test/unit/instruments/net_http_test.rb +21 -0
  97. data/test/unit/instruments/percentile_sampler_test.rb +137 -0
  98. data/test/unit/layaway_test.rb +20 -0
  99. data/test/unit/layer_children_set_test.rb +88 -0
  100. data/test/unit/layer_converters/depth_first_walker_test.rb +66 -0
  101. data/test/unit/layer_converters/metric_converter_test.rb +22 -0
  102. data/test/unit/layer_converters/stubs.rb +33 -0
  103. data/test/unit/limited_layer_test.rb +53 -0
  104. data/test/unit/remote/test_message.rb +13 -0
  105. data/test/unit/remote/test_router.rb +33 -0
  106. data/test/unit/remote/test_server.rb +15 -0
  107. data/test/unit/serializers/payload_serializer_test.rb +3 -12
  108. data/test/unit/store_test.rb +66 -0
  109. data/test/unit/test_tracked_request.rb +87 -0
  110. data/test/unit/utils/active_record_metric_name_test.rb +8 -0
  111. data/test/unit/utils/backtrace_parser_test.rb +5 -0
  112. data/test/unit/utils/numbers_test.rb +15 -0
  113. data/test/unit/utils/scm.rb +17 -0
  114. metadata +125 -30
  115. data/ext/stacks/extconf.rb +0 -37
  116. data/ext/stacks/scout_atomics.h +0 -86
  117. data/ext/stacks/stacks.c +0 -811
  118. data/lib/scout_apm/capacity.rb +0 -57
  119. data/lib/scout_apm/deploy_integrations/capistrano_2.cap +0 -12
  120. data/lib/scout_apm/deploy_integrations/capistrano_2.rb +0 -83
  121. data/lib/scout_apm/deploy_integrations/capistrano_3.cap +0 -12
  122. data/lib/scout_apm/deploy_integrations/capistrano_3.rb +0 -88
  123. data/lib/scout_apm/instruments/delayed_job.rb +0 -57
  124. data/lib/scout_apm/serializers/deploy_serializer.rb +0 -16
  125. data/lib/scout_apm/trace_compactor.rb +0 -312
  126. data/lib/scout_apm/utils/fake_stacks.rb +0 -87
  127. data/tester.rb +0 -53
@@ -0,0 +1,57 @@
1
+ module ScoutApm
2
+ module Remote
3
+ class Recorder
4
+ attr_reader :logger
5
+ attr_reader :remote_agent_host
6
+ attr_reader :remote_agent_port
7
+
8
+ def initialize(remote_agent_host, remote_agent_port, logger)
9
+ @remote_agent_host = remote_agent_host
10
+ @remote_agent_port = remote_agent_port
11
+ @logger = logger
12
+ end
13
+
14
+ def start
15
+ # nothing to do
16
+ self
17
+ end
18
+
19
+ def stop
20
+ # nothing to do
21
+ end
22
+
23
+ def record!(request)
24
+ begin
25
+ t1 = Time.now
26
+ # Mark this request as recorded, so the next lookup on this thread, it
27
+ # can be recreated
28
+ request.recorded!
29
+
30
+ # Only send requests that we actually want. Incidental http &
31
+ # background thread stuff can just be dropped
32
+ unless request.job? || request.web?
33
+ return
34
+ end
35
+
36
+ request.prepare_to_dump!
37
+ message = ScoutApm::Remote::Message.new('record', 'record!', request)
38
+ encoded = message.encode
39
+ logger.debug "Remote Agent: Posting a message of length: #{encoded.length}"
40
+ post(encoded)
41
+ t2 = Time.now
42
+
43
+ logger.debug("Remote Recording took: #{t2.to_f - t1.to_f} seconds")
44
+ rescue => e
45
+ logger.debug "Remote: Error while sending to collector: #{e.inspect}, #{e.backtrace.join("\n")}"
46
+ end
47
+ end
48
+
49
+ def post(encoded_message)
50
+ http = Net::HTTP.new(remote_agent_host, remote_agent_port)
51
+ request = Net::HTTP::Post.new("/users")
52
+ request.body = encoded_message
53
+ response = http.request(request)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,49 @@
1
+ module ScoutApm
2
+ module Remote
3
+ class Router
4
+ attr_reader :logger
5
+ attr_reader :routes
6
+
7
+ # If/When we add different types, this signature should change to a hash
8
+ # of {type => Object}, rather than building it in the initializer here.
9
+ #
10
+ # Keys of routes should be strings
11
+ def initialize(recorder, logger)
12
+ @routes = {
13
+ 'record' => recorder
14
+ }
15
+
16
+ @logger = logger
17
+ end
18
+
19
+ # A message is a 2 element array [:type, :command, [args]].
20
+ # For this first creation, this should be ['record', 'record', [TrackedRequest]] (the args arg should always be an array, even w/ only 1 item)
21
+ #
22
+ # Where
23
+ # type: ['recorder']
24
+ # command: any function supported on that type of object
25
+ # args: any array of arguments
26
+ #
27
+ # Raises on unknown message
28
+ #
29
+ # Returns whatever the recipient object returns
30
+ def handle(msg)
31
+ message = Remote::Message.decode(msg)
32
+ assert_type(message)
33
+ call_route(message)
34
+ end
35
+
36
+ private
37
+
38
+ def assert_type(message)
39
+ if ! routes.keys.include?(message.type.to_s)
40
+ raise "Unknown type: #{message.type.to_s}"
41
+ end
42
+ end
43
+
44
+ def call_route(message)
45
+ routes[message.type].send(message.command, *message.args)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,58 @@
1
+ # Web Server bound to localhost that listens for remote agent reports. Forwards
2
+ # onto the router
3
+ module ScoutApm
4
+ module Remote
5
+ class Server
6
+ attr_reader :router
7
+ attr_reader :bind
8
+ attr_reader :port
9
+ attr_reader :logger
10
+
11
+ def initialize(bind, port, router, logger)
12
+ @router = router
13
+ @logger = logger
14
+ @bind = bind
15
+ @port = port
16
+ @server = nil
17
+ end
18
+
19
+ def start
20
+ @server = WEBrick::HTTPServer.new(
21
+ :BindAddress => bind,
22
+ :Port => port,
23
+ :AccessLog => [],
24
+ :Logger => @logger
25
+ )
26
+
27
+ @server.mount_proc '/' do |request, response|
28
+ router.handle(request.body)
29
+
30
+ # arbitrary response, client doesn't expect anything in particular
31
+ response.body = 'Ok'
32
+ end
33
+
34
+ @thread = Thread.new do
35
+ begin
36
+ logger.debug("Remote: Starting Server on #{bind}:#{port}")
37
+
38
+ @server.start
39
+
40
+ logger.debug("Remote: Server returned after #start call, thread exiting")
41
+ rescue => e
42
+ logger.debug("Remote: Server Exception, #{e}")
43
+ end
44
+ end
45
+ end
46
+
47
+ def running?
48
+ @thread.alive?
49
+ @server && @server.status == :Running
50
+ end
51
+
52
+ def stop
53
+ @server.stop
54
+ @thread.kill
55
+ end
56
+ end
57
+ end
58
+ end
@@ -17,31 +17,36 @@ module ScoutApm
17
17
  @instant_key = instant_key
18
18
  end
19
19
 
20
- # TODO: Parse & return a real response object, not the HTTP Response object
21
20
  def report(payload, headers = {})
22
- # Some posts (typically ones under development) bypass the ingestion pipeline and go directly to the webserver. They use direct_host instead of host
23
- hosts = [:deploy_hook, :instant_trace].include?(type) ? config.value('direct_host') : config.value('host')
21
+ hosts = determine_hosts
24
22
 
25
- Array(hosts).each do |host|
26
- full_uri = uri(host)
27
- response = post(full_uri, payload, headers)
28
- unless response && response.is_a?(Net::HTTPSuccess)
29
- logger.warn "Error on checkin to #{full_uri.to_s}: #{response.inspect}"
30
- end
23
+ if config.value('compress_payload')
24
+ original_payload_size = payload.length
25
+
26
+ payload, compression_headers = compress_payload(payload)
27
+ headers.merge!(compression_headers)
28
+
29
+ compress_payload_size = payload.length
30
+ ScoutApm::Agent.instance.logger.debug("Original Size: #{original_payload_size} Compressed Size: #{compress_payload_size}")
31
31
  end
32
+
33
+ post_payload(hosts, payload, headers)
32
34
  end
33
35
 
34
36
  def uri(host)
37
+ encoded_app_name = CGI.escape(Environment.instance.application_name)
38
+ key = config.value('key')
39
+
35
40
  case type
36
41
  when :checkin
37
- URI.parse("#{host}/apps/checkin.scout?key=#{config.value('key')}&name=#{CGI.escape(Environment.instance.application_name)}")
42
+ URI.parse("#{host}/apps/checkin.scout?key=#{key}&name=#{encoded_app_name}")
38
43
  when :app_server_load
39
- URI.parse("#{host}/apps/app_server_load.scout?key=#{config.value('key')}&name=#{CGI.escape(Environment.instance.application_name)}")
44
+ URI.parse("#{host}/apps/app_server_load.scout?key=#{key}&name=#{encoded_app_name}")
40
45
  when :deploy_hook
41
- URI.parse("#{host}/apps/deploy.scout?key=#{config.value('key')}&name=#{CGI.escape(config.value('name'))}")
46
+ URI.parse("#{host}/apps/deploy.scout?key=#{key}&name=#{encoded_app_name}")
42
47
  when :instant_trace
43
- URI.parse("#{host}/apps/instant_trace.scout?key=#{config.value('key')}&name=#{CGI.escape(config.value('name'))}&instant_key=#{instant_key}")
44
- end.tap{|u| logger.debug("Posting to #{u.to_s}")}
48
+ URI.parse("#{host}/apps/instant_trace.scout?key=#{key}&name=#{encoded_app_name}&instant_key=#{instant_key}")
49
+ end.tap { |u| logger.debug("Posting to #{u}") }
45
50
  end
46
51
 
47
52
  def can_report?
@@ -106,7 +111,10 @@ module ScoutApm
106
111
  # Net::HTTP::Proxy returns a regular Net::HTTP class if the first argument (host) is nil.
107
112
  def http(url)
108
113
  proxy_uri = URI.parse(config.value('proxy').to_s)
109
- http = Net::HTTP::Proxy(proxy_uri.host,proxy_uri.port,proxy_uri.user,proxy_uri.password).new(url.host, url.port)
114
+ http = Net::HTTP::Proxy(proxy_uri.host,
115
+ proxy_uri.port,
116
+ proxy_uri.user,
117
+ proxy_uri.password).new(url.host, url.port)
110
118
  if url.is_a?(URI::HTTPS)
111
119
  http.use_ssl = true
112
120
  http.ca_file = CA_FILE
@@ -114,5 +122,33 @@ module ScoutApm
114
122
  end
115
123
  http
116
124
  end
125
+
126
+ def compress_payload(payload)
127
+ [
128
+ ScoutApm::Utils::GzipHelper.new.deflate(payload),
129
+ { 'Content-Encoding' => 'gzip' }
130
+ ]
131
+ end
132
+
133
+ # Some posts (typically ones under development) bypass the ingestion
134
+ # pipeline and go directly to the webserver. They use direct_host instead
135
+ # of host
136
+ def determine_hosts
137
+ if [:deploy_hook, :instant_trace].include?(type)
138
+ config.value('direct_host')
139
+ else
140
+ config.value('host')
141
+ end
142
+ end
143
+
144
+ def post_payload(hosts, payload, headers)
145
+ Array(hosts).each do |host|
146
+ full_uri = uri(host)
147
+ response = post(full_uri, payload, headers)
148
+ unless response && response.is_a?(Net::HTTPSuccess)
149
+ logger.warn "Error on checkin to #{full_uri}: #{response.inspect}"
150
+ end
151
+ end
152
+ end
117
153
  end
118
154
  end
@@ -39,6 +39,10 @@ module ScoutApm
39
39
  initialize_histograms_hash
40
40
  end
41
41
 
42
+ def raw(item)
43
+ @histograms[item]
44
+ end
45
+
42
46
  def initialize_histograms_hash
43
47
  @histograms = Hash.new { |h, k| h[k] = NumericHistogram.new(histogram_size) }
44
48
  end
@@ -11,7 +11,7 @@ module ScoutApm
11
11
  def self.find
12
12
  req = Thread.current[:scout_request]
13
13
 
14
- if req && req.recorded?
14
+ if req && (req.stopping? || req.recorded?)
15
15
  nil
16
16
  else
17
17
  req
@@ -25,6 +25,7 @@ module ScoutApm
25
25
  else
26
26
  ScoutApm::FakeStore.new
27
27
  end
28
+
28
29
  Thread.current[:scout_request] = TrackedRequest.new(store)
29
30
  end
30
31
  end
@@ -63,6 +63,12 @@ module ScoutApm
63
63
  end
64
64
  end
65
65
 
66
+ # Equal to another set only if exactly the same set of items is inside
67
+ def eql?(other)
68
+ items == other.items
69
+ end
70
+
71
+ alias :== :eql?
66
72
 
67
73
  private
68
74
 
@@ -75,5 +81,6 @@ module ScoutApm
75
81
  items[new_item.name] = [new_item.score, new_item.call]
76
82
  end
77
83
  end
84
+
78
85
  end
79
86
  end
@@ -0,0 +1,15 @@
1
+ module ScoutApm
2
+ module Serializers
3
+ class DbQuerySerializerToJson
4
+ attr_reader :db_query_metrics
5
+
6
+ def initialize(db_query_metrics)
7
+ @db_query_metrics = db_query_metrics
8
+ end
9
+
10
+ def as_json
11
+ db_query_metrics.map{|metric| metric.as_json }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+
2
+ module ScoutApm
3
+ module Serializers
4
+ class HistogramsSerializerToJson
5
+ attr_reader :histograms
6
+
7
+ def initialize(histograms)
8
+ @histograms = histograms
9
+ end
10
+
11
+ def as_json
12
+ histograms.map do |histo|
13
+ {
14
+ "name" => histo.name,
15
+ "histogram" => histo.histogram.as_json,
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,9 +2,9 @@
2
2
  module ScoutApm
3
3
  module Serializers
4
4
  class PayloadSerializer
5
- def self.serialize(metadata, metrics, slow_transactions, jobs, slow_jobs)
5
+ def self.serialize(metadata, metrics, slow_transactions, jobs, slow_jobs, histograms, db_query_metrics)
6
6
  if ScoutApm::Agent.instance.config.value("report_format") == 'json'
7
- ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, metrics, slow_transactions, jobs, slow_jobs)
7
+ ScoutApm::Serializers::PayloadSerializerToJson.serialize(metadata, metrics, slow_transactions, jobs, slow_jobs, histograms, db_query_metrics)
8
8
  else
9
9
  metadata = metadata.dup
10
10
  metadata.default = nil
@@ -15,7 +15,14 @@ module ScoutApm
15
15
  :metrics => metrics,
16
16
  :slow_transactions => slow_transactions,
17
17
  :jobs => jobs,
18
- :slow_jobs => slow_jobs)
18
+ :slow_jobs => slow_jobs,
19
+
20
+ # as_json returns a ruby object. Since it's not a simple
21
+ # array, use this to maintain compatibility with json
22
+ # payloads. At this point, the marshal code branch is
23
+ # very rarely used anyway.
24
+ :histograms => HistogramsSerializerToJson.new(histograms).as_json,
25
+ :db_query_metrics => db_query_metrics)
19
26
  end
20
27
  end
21
28
 
@@ -2,7 +2,7 @@ module ScoutApm
2
2
  module Serializers
3
3
  module PayloadSerializerToJson
4
4
  class << self
5
- def serialize(metadata, metrics, slow_transactions, jobs, slow_jobs)
5
+ def serialize(metadata, metrics, slow_transactions, jobs, slow_jobs, histograms, db_query_metrics)
6
6
  metadata.merge!({:payload_version => 2})
7
7
 
8
8
  jsonify_hash({:metadata => metadata,
@@ -10,7 +10,11 @@ module ScoutApm
10
10
  :slow_transactions => rearrange_the_slow_transactions(slow_transactions),
11
11
  :jobs => JobsSerializerToJson.new(jobs).as_json,
12
12
  :slow_jobs => SlowJobsSerializerToJson.new(slow_jobs).as_json,
13
- })
13
+ :histograms => HistogramsSerializerToJson.new(histograms).as_json,
14
+ :db_metrics => {
15
+ :query => DbQuerySerializerToJson.new(db_query_metrics).as_json,
16
+ },
17
+ })
14
18
  end
15
19
 
16
20
  # For the old style of metric serializing.
@@ -67,10 +71,6 @@ module ScoutApm
67
71
  %Q["#{formatee.iso8601}"]
68
72
  when nil
69
73
  "null"
70
- when TrueClass
71
- "true"
72
- when FalseClass
73
- "false"
74
74
  else # strings and everything
75
75
  %Q["#{escape(formatee)}"]
76
76
  end
@@ -21,9 +21,11 @@ module ScoutApm
21
21
  "allocations" => job.allocations,
22
22
  "seconds_since_startup" => job.seconds_since_startup,
23
23
  "hostname" => job.hostname,
24
+ "git_sha" => job.git_sha,
24
25
  "metrics" => MetricsToJsonSerializer.new(job.metrics).as_json, # New style of metrics
25
26
  "allocation_metrics" => MetricsToJsonSerializer.new(job.allocation_metrics).as_json, # New style of metrics
26
27
  "context" => job.context.to_hash,
28
+ "truncated_metrics" => job.truncated_metrics,
27
29
 
28
30
  "score" => job.score,
29
31
  }
@@ -32,4 +34,3 @@ module ScoutApm
32
34
  end
33
35
  end
34
36
  end
35
-
@@ -24,10 +24,13 @@ module ScoutApm
24
24
  end
25
25
 
26
26
  def install
27
- ::Puma.cli_config.options[:before_worker_boot] << Proc.new do
27
+ old = ::Puma.cli_config.options[:before_worker_boot] || []
28
+ new = Array(old) + [Proc.new do
28
29
  logger.info "Installing Puma worker loop."
29
30
  ScoutApm::Agent.instance.start_background_worker
30
- end
31
+ end]
32
+
33
+ ::Puma.cli_config.options[:before_worker_boot] = new
31
34
  rescue
32
35
  logger.warn "Unable to install Puma worker loop: #{$!.message}"
33
36
  end