scout_apm 3.0.0.pre15 → 3.0.0.pre16

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: 8acb94ef4095b224ee2d08a3d5a25410b104447b
4
- data.tar.gz: 7d6493404c2dcd0346d6465d240cb428eb1f23ab
3
+ metadata.gz: 48d7c95db58d0248a431b10cb8501128892ed804
4
+ data.tar.gz: cee8126c3395ee5b45c2c42b4523d95e901f2817
5
5
  SHA512:
6
- metadata.gz: e3f6cd0b3fb6413bc36a18b69a7e24ed6cb65d7f32f0b0d9ce5bef7b71b41640e80a34c8255540b9d8171312bca630bf35d79568ad7976bb6d0e83f7fe8f4253
7
- data.tar.gz: 885869be52cb6836df31063bcb2818433511e6001115490e926256de2c70d924452a1feed70ad4a8501155388520ae8efff12a77584f653e6499ae269c2212e5
6
+ metadata.gz: 84c6a1840c5bbdba0770967ded0a6de09d396080c384044c723a53a872ce0b6fec3aa83bf930f8f8f3709f9a50f6b896e3641d53dbe7f9428769ff158b5a49d8
7
+ data.tar.gz: fe384265d5792579373739d283da2efbcd3eb4fb1f32b0e4281100154b8050b321f7c8bf751ca38fb136e06e5c33cab9366359c80a22e0d90ac9feed180140fa
data/lib/scout_apm.rb CHANGED
@@ -15,7 +15,6 @@ require 'thread'
15
15
  require 'time'
16
16
  require 'yaml'
17
17
  require 'rbconfig'
18
- require 'webrick'
19
18
 
20
19
  #####################################
21
20
  # Gem Requires
@@ -43,18 +43,18 @@ module ScoutApm
43
43
  install_background_job_integrations
44
44
  install_app_server_integration
45
45
 
46
- # XXX: Should this happen at application start?
47
- # Should this ever happen after fork?
48
- # We start a thread in this, which can screw stuff up when we then fork.
49
- #
50
- # Save it into a variable to prevent it from ever running twice
51
- @app_server_load ||= AppServerLoad.new(context).run
52
-
53
46
  logger.info "Scout Agent [#{ScoutApm::VERSION}] installed"
54
47
 
55
48
  context.installed!
56
49
 
57
50
  if ScoutApm::Agent::Preconditions.check?(context) || force
51
+ # XXX: Should this happen at application start?
52
+ # Should this ever happen after fork?
53
+ # We start a thread in this, which can screw stuff up when we then fork.
54
+ #
55
+ # Save it into a variable to prevent it from ever running twice
56
+ @app_server_load ||= AppServerLoad.new(context).run
57
+
58
58
  start
59
59
  end
60
60
  end
@@ -124,9 +124,7 @@ module ScoutApm
124
124
 
125
125
  def should_load_instruments?
126
126
  return true if context.config.value('dev_trace')
127
- # XXX: If monitor is true, we want to install, right?
128
- # return false if context.config.value('monitor')
129
- context.environment.app_server_integration.found? || context.environment.background_job_integration
127
+ context.environment.app_server_integration.found? || context.environment.background_job_integrations.any?
130
128
  end
131
129
 
132
130
  #################################
@@ -102,10 +102,16 @@ module ScoutApm
102
102
  end
103
103
  elsif job_class == DELAYED_WRAPPER_KLASS
104
104
  begin
105
+ # Extract the info out of the wrapper
105
106
  yml = msg['args'].first
106
107
  deserialized_args = YAML.load(yml)
107
108
  klass, method, *rest = deserialized_args
108
- job_class = [klass,method].map(&:to_s).join(".")
109
+
110
+ # If this is an instance of a class, get the class itself
111
+ # Prevents instances from coming through named like "#<Foo:0x007ffd7a9dd8a0>"
112
+ klass = klass.class unless klass.is_a? Module
113
+
114
+ job_class = [klass, method].map(&:to_s).join(".")
109
115
  rescue
110
116
  DELAYED_WRAPPER_KLASS
111
117
  end
@@ -51,7 +51,8 @@ module ScoutApm
51
51
 
52
52
  def write_reporting_period(reporting_period, files_limit = MAX_FILES_LIMIT)
53
53
  if at_layaway_file_limit?(files_limit)
54
- logger.error("Hit layaway file limit. Not writing to layaway file")
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
56
  return false
56
57
  end
57
58
  filename = file_for(reporting_period.timestamp)
@@ -59,9 +60,22 @@ module ScoutApm
59
60
  layaway_file.write(reporting_period)
60
61
  end
61
62
 
62
- # Claims a given timestamp (getting a lock on a particular filename),
63
- # then yields ReportingPeriods collected up from all the files.
64
- # If the yield returns truthy, delete the layaway files that made it up.
63
+ # Claims a given timestamp by getting an exclusive lock on a timestamped
64
+ # coordinator file. The coordinator file never contains data, it's just a
65
+ # syncronization mechanism.
66
+ #
67
+ # Once the 'claim' is obtained:
68
+ # * load and yield each ReportingPeriod from the layaway files.
69
+ # * if there are reporting periods:
70
+ # * yields any ReportingPeriods collected up from all the files.
71
+ # * deletes all of the layaway files (including the coordinator) for the timestamp
72
+ # * if not
73
+ # * delete the coordinator
74
+ # * remove any stale layaway files that may be hanging around.
75
+ # * Finally unlock and ensure the coordinator file is cleared.
76
+ #
77
+ # If a claim file can't be obtained, return false without doing any work
78
+ # Another process is handling the reporting.
65
79
  def with_claim(timestamp)
66
80
  coordinator_file = glob_pattern(timestamp, :coordinator)
67
81
 
@@ -86,14 +100,14 @@ module ScoutApm
86
100
 
87
101
  logger.debug("Deleting the now-reported layaway files for #{timestamp.to_s}")
88
102
  delete_files_for(timestamp) # also removes the coodinator_file
89
-
90
- logger.debug("Checking for any Stale layaway files")
91
- delete_stale_files(timestamp.to_time - STALE_AGE)
92
103
  else
93
104
  File.unlink(coordinator_file)
94
105
  logger.debug("No layaway files to report")
95
106
  end
96
107
 
108
+ logger.debug("Checking for any Stale layaway files")
109
+ delete_stale_files(timestamp.to_time - STALE_AGE)
110
+
97
111
  true
98
112
  rescue Exception => e
99
113
  logger.debug("Caught an exception in with_claim, with the coordination file locked: #{e.message}, #{e.backtrace.inspect}")
@@ -17,6 +17,8 @@ module ScoutApm
17
17
  end
18
18
 
19
19
  def start
20
+ require 'webrick'
21
+
20
22
  @server = WEBrick::HTTPServer.new(
21
23
  :BindAddress => bind,
22
24
  :Port => port,
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "3.0.0.pre15"
2
+ VERSION = "3.0.0.pre16"
3
3
  end
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: 3.0.0.pre15
4
+ version: 3.0.0.pre16
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-02 00:00:00.000000000 Z
12
+ date: 2018-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -372,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
372
372
  version: 1.3.1
373
373
  requirements: []
374
374
  rubyforge_project: scout_apm
375
- rubygems_version: 2.5.2.1
375
+ rubygems_version: 2.4.5.2
376
376
  signing_key:
377
377
  specification_version: 4
378
378
  summary: Ruby application performance monitoring