scout_apm 2.4.4 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9ba2d44228de2ea17e70a87425b7e7a3d6ebc34
4
- data.tar.gz: ebf97e1ddd39bfeefc70a5d559b8040e3f7f5657
3
+ metadata.gz: c7cca5bcac3a1e0003177c2278f946cc8f91162e
4
+ data.tar.gz: 1019c41baada305983347b46a89d201959fd6a0d
5
5
  SHA512:
6
- metadata.gz: f00ff64d371bcf47ba2cd5cf19f2b6c3091c2b6b1f5fefd8f82e2354490295750e155fc88165e2357ddc8110d396420e4e04374589687ea50a878797c411ec0b
7
- data.tar.gz: 4c0e9ab6e524a65c94e97b4860e843945c55e4fca30c4870325b83a6747a9eb057342da9abc8ec6c8bab3920077aaea178c687261d2676ef79d6c07de74e48ea
6
+ metadata.gz: 1e82600c59d5214af9f3e4eea0c41c9c5a2d3fffda05d6fa33f38cf65e410728bd82a789f39150a76b4569f9631a85af65cc8e6b84ceb1630b4f7eb96393cb14
7
+ data.tar.gz: 5a50add27950b1ee9080a6f803feed0ee8cfe05ac730dc19fc47980e5ec15729663f41c7b3889feca87380602f7a284005d6f4f821ebb9dd8f25a5c42dea947f
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.4.5
2
+
3
+ * More robust installation of instruments at startup
4
+ * Several (very) minor bug fixes
5
+
1
6
  # 2.4.4
2
7
 
3
8
  * Prevent agent from starting when monitor=false
data/lib/scout_apm.rb CHANGED
@@ -196,5 +196,5 @@ if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR
196
196
  end
197
197
  end
198
198
  else
199
- ScoutApm::Agent.instance.start
199
+ ScoutApm::Agent.instance.install
200
200
  end
@@ -35,15 +35,14 @@ module ScoutApm
35
35
  def install(force=false)
36
36
  context.config = ScoutApm::Config.with_file(context, context.config.value("config_file"))
37
37
 
38
- context.logger.info "Scout Agent [#{ScoutApm::VERSION}] Initialized"
38
+ logger.info "Scout Agent [#{ScoutApm::VERSION}] Initialized"
39
39
 
40
- @instrument_manager = ScoutApm::InstrumentManager.new(context)
41
- @instrument_manager.install! if should_load_instruments? || force
40
+ instrument_manager.install! if should_load_instruments? || force
42
41
 
43
42
  install_background_job_integrations
44
43
  install_app_server_integration
45
44
 
46
- logger.info "Scout Agent [#{ScoutApm::VERSION}] installed"
45
+ logger.info "Scout Agent [#{ScoutApm::VERSION}] Installed"
47
46
 
48
47
  context.installed!
49
48
 
@@ -69,6 +68,8 @@ module ScoutApm
69
68
 
70
69
  install unless context.installed?
71
70
 
71
+ instrument_manager.install! if should_load_instruments?
72
+
72
73
  context.started!
73
74
 
74
75
  log_environment
@@ -79,6 +80,10 @@ module ScoutApm
79
80
  start_background_worker
80
81
  end
81
82
 
83
+ def instrument_manager
84
+ @instrument_manager ||= ScoutApm::InstrumentManager.new(context)
85
+ end
86
+
82
87
  def log_environment
83
88
  bg_names = context.environment.background_job_integrations.map{|bg| bg.name }.join(", ")
84
89
 
@@ -123,10 +128,13 @@ module ScoutApm
123
128
  return !context.environment.forking?
124
129
  end
125
130
 
131
+ # monitor is the key configuration here. If it is true, then we want the
132
+ # instruments. If it is false, we mostly don't want them, unless you're
133
+ # asking for devtrace (ie. not reporting to apm servers as a real app, but
134
+ # only for local browsers).
126
135
  def should_load_instruments?
127
136
  return true if context.config.value('dev_trace')
128
- return false unless context.config.value('monitor')
129
- context.environment.app_server_integration.found? || context.environment.background_job_integrations.any?
137
+ context.config.value('monitor')
130
138
  end
131
139
 
132
140
  #################################
@@ -37,5 +37,8 @@ module ScoutApm
37
37
 
38
38
  def add_sampler(sampler)
39
39
  end
40
+
41
+ def tick!
42
+ end
40
43
  end
41
44
  end
@@ -52,12 +52,16 @@ module ScoutApm
52
52
  def write_reporting_period(reporting_period, files_limit = MAX_FILES_LIMIT)
53
53
  if at_layaway_file_limit?(files_limit)
54
54
  # This will happen constantly once we hit this case, so only log the first time
55
- @wrote_layaway_limit_error_message ||= logger.error("Hit layaway file limit. Not writing to layaway file")
55
+ @wrote_layaway_limit_error_message ||= logger.error("Layaway: Hit layaway file limit. Not writing to layaway file")
56
56
  return false
57
57
  end
58
+ logger.debug("Layaway: wrote time period: #{reporting_period.timestamp}")
58
59
  filename = file_for(reporting_period.timestamp)
59
60
  layaway_file = LayawayFile.new(context, filename)
60
61
  layaway_file.write(reporting_period)
62
+ rescue => e
63
+ logger.debug("Layaway: error writing: #{e.message}, #{e.backtrace.inspect}")
64
+ raise e
61
65
  end
62
66
 
63
67
  # Claims a given timestamp by getting an exclusive lock on a timestamped
@@ -98,19 +102,19 @@ module ScoutApm
98
102
  if rps.any?
99
103
  yield rps
100
104
 
101
- logger.debug("Deleting the now-reported layaway files for #{timestamp.to_s}")
105
+ logger.debug("Layaway: Deleting the now-reported files for #{timestamp.to_s}")
102
106
  delete_files_for(timestamp) # also removes the coodinator_file
103
107
  else
104
108
  File.unlink(coordinator_file)
105
- logger.debug("No layaway files to report")
109
+ logger.debug("Layaway: No files to report")
106
110
  end
107
111
 
108
- logger.debug("Checking for any Stale layaway files")
112
+ logger.debug("Layaway: Checking for any stale files")
109
113
  delete_stale_files(timestamp.to_time - STALE_AGE)
110
114
 
111
115
  true
112
116
  rescue Exception => e
113
- logger.debug("Caught an exception in with_claim, with the coordination file locked: #{e.message}, #{e.backtrace.inspect}")
117
+ logger.debug("Layaway: Caught an exception in with_claim, with the coordination file locked: #{e.message}, #{e.backtrace.inspect}")
114
118
  raise
115
119
  ensure
116
120
  # Unlock the file when done!
@@ -126,7 +130,7 @@ module ScoutApm
126
130
 
127
131
  def delete_files_for(timestamp)
128
132
  all_files_for(timestamp).each { |layaway|
129
- logger.debug("Deleting layaway file: #{layaway}")
133
+ logger.debug("Layaway: Deleting file: #{layaway}")
130
134
  File.unlink(layaway)
131
135
  }
132
136
  end
@@ -137,10 +141,10 @@ module ScoutApm
137
141
  compact.
138
142
  uniq.
139
143
  select { |timestamp| timestamp.to_i < older_than.strftime(TIME_FORMAT).to_i }.
140
- tap { |timestamps| logger.debug("Deleting stale layaway files with timestamps: #{timestamps.inspect}") }.
144
+ tap { |timestamps| logger.debug("Layaway: Deleting stale files with timestamps: #{timestamps.inspect}") }.
141
145
  map { |timestamp| delete_files_for(timestamp) }
142
146
  rescue => e
143
- logger.debug("Problem deleting stale files: #{e.message}, #{e.backtrace.inspect}")
147
+ logger.debug("Layaway: Problem deleting stale files: #{e.message}, #{e.backtrace.inspect}")
144
148
  end
145
149
 
146
150
  private
@@ -206,8 +210,7 @@ module ScoutApm
206
210
  map{ |timestamp, list| [timestamp, list.length] }
207
211
  ]
208
212
 
209
-
210
- logger.debug("Total in #{directory}: #{files_in_temp}. Total Layaway Files: #{all_filenames.size}. By Timestamp: #{count_per_timestamp.inspect}")
213
+ logger.debug("Layaway: Total Files in #{directory}: #{files_in_temp}. Total Layaway Files: #{all_filenames.size}. By Timestamp: #{count_per_timestamp.inspect}")
211
214
  end
212
215
  end
213
216
  end
@@ -6,6 +6,7 @@ module ScoutApm
6
6
 
7
7
  def initialize(context, path)
8
8
  @path = path
9
+ @context = context
9
10
  end
10
11
 
11
12
  def logger
@@ -17,7 +18,7 @@ module ScoutApm
17
18
  deserialize(data)
18
19
  rescue NameError, ArgumentError, TypeError => e
19
20
  # Marshal error
20
- logger.info("Unable to load data from Layaway file, resetting.")
21
+ logger.info("LayawayFile: Unable to load data")
21
22
  logger.debug("#{e.message}, #{e.backtrace.join("\n\t")}")
22
23
  nil
23
24
  end
@@ -24,6 +24,9 @@ module ScoutApm
24
24
  #
25
25
  # At any given point, there is data in each of those steps, moving its way through the process
26
26
  def process_metrics
27
+ # Do any per-minute work necessary for the store
28
+ context.store.tick!
29
+
27
30
  # Write the previous minute's data to the shared-across-process layaway file.
28
31
  context.store.write_to_layaway(context.layaway)
29
32
 
@@ -88,10 +88,15 @@ module ScoutApm
88
88
  logger.debug("Writing to layaway#{" (Forced)" if force}")
89
89
 
90
90
  @reporting_periods.select { |time, rp| force || (time.timestamp < current_timestamp.timestamp) }.
91
- each { |time, rp| collect_samplers(rp) }.
92
91
  each { |time, rp| write_reporting_period(layaway, time, rp) }
93
92
  end
94
93
 
94
+ # For each tick (minute), be sure we have a reporting period, and that samplers are run for it.
95
+ def tick!
96
+ rp = current_period
97
+ collect_samplers(rp)
98
+ end
99
+
95
100
  def write_reporting_period(layaway, time, rp)
96
101
  @mutex.synchronize {
97
102
  layaway.write_reporting_period(rp)
@@ -299,10 +299,6 @@ module ScoutApm
299
299
  def ensure_background_worker
300
300
  agent = ScoutApm::Agent.instance
301
301
  agent.start
302
-
303
- if agent.start_background_worker(:quiet)
304
- agent.logger.info("Force Started BG Worker")
305
- end
306
302
  rescue => e
307
303
  true
308
304
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.4.4"
2
+ VERSION = "2.4.5"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Haynes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-23 00:00:00.000000000 Z
12
+ date: 2018-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest