scout_apm 0.9.6 → 0.9.7.pre

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: b45b445e6890d21e6a92c1e35684b89a8104f06c
4
- data.tar.gz: 86e98c9d8f952de077c7b35d372b21f2f217be4c
3
+ metadata.gz: 98536a2a26a3dcd0f508a214ff53710d434787ac
4
+ data.tar.gz: fd7667d714f25b323c5e05d76ef358f8cbcebf01
5
5
  SHA512:
6
- metadata.gz: 69453628027b2cf8d95828342ee27eefc82fc5f17ad2c5f2fba9d1c0fd67f0f2bde3067cc95117086bd338e842b35ae28b09d1e924227b9ded5aa5e88309ca37
7
- data.tar.gz: 31ad198f6b219fcef29085a15a8f7feeb9ba814f350d214f29ce468a9854c6a423f3896b8318f4608e34fe90f3d7b41d7ac91291d5cd3b020779d2172bacdd81
6
+ metadata.gz: e27f3d446948abc9683e773ae753d0bc22e84035f5e23edf3b934e68e46eb0c3864f8b90359d226ccd4c2600f0b935333d388f78f3963463ceb204179e19661d
7
+ data.tar.gz: 4d6f0bee9eb790d984e1a54dbbfc395120b12c4fb0a8e1dae339bd39a6f8d44790024828cdc7d23462a2b9d1cae154f4779608ecc9ddf1631aff8c0ba4b33f30
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.9.7
2
+
3
+ * Added Cloud Foundry detection
4
+ * Added hostname config option
5
+ * Reporting PaaS in app server load (Heroku or Cloud Foundry).
6
+
1
7
  # 0.9.6
2
8
 
3
9
  * Fix more 1.8.7 syntax errors
data/lib/scout_apm.rb CHANGED
@@ -85,11 +85,19 @@ require 'scout_apm/serializers/directive_serializer'
85
85
  require 'scout_apm/serializers/app_server_load_serializer'
86
86
  require 'scout_apm/serializers/deploy_serializer'
87
87
 
88
- if defined?(Rails) and Rails.respond_to?(:version) and Rails.version >= '3'
88
+ require 'scout_apm/middleware'
89
+
90
+ if defined?(Rails) && defined?(Rails::VERSION) && defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR >= 3
89
91
  module ScoutApm
90
92
  class Railtie < Rails::Railtie
91
93
  initializer "scout_apm.start" do |app|
94
+ # Attempt to start right away, this will work best for preloading apps, Unicorn & Puma & similar
92
95
  ScoutApm::Agent.instance.start
96
+
97
+ # And attempt to start on first-request, which is a good catch-all for
98
+ # Webrick, and Passenger and similar, where we can't detect the running app server
99
+ # until actual requests come in.
100
+ app.middleware.use ScoutApm::Middleware
93
101
  end
94
102
  end
95
103
  end
@@ -47,7 +47,7 @@ module ScoutApm
47
47
  config.value('monitor') and !@options[:force]
48
48
  end
49
49
 
50
- def preconditions_met?
50
+ def preconditions_met?(options={})
51
51
  if !apm_enabled?
52
52
  logger.warn "Monitoring isn't enabled for the [#{environment.env}] environment."
53
53
  return false
@@ -58,7 +58,7 @@ module ScoutApm
58
58
  return false
59
59
  end
60
60
 
61
- if !environment.app_server_integration.found?
61
+ if !environment.app_server_integration(true).found? && !options[:skip_app_server_check]
62
62
  logger.warn "Couldn't find a supported app server. Not starting agent."
63
63
  return false
64
64
  end
@@ -88,7 +88,7 @@ module ScoutApm
88
88
  return environment.deploy_integration.install
89
89
  end
90
90
 
91
- return false unless preconditions_met?
91
+ return false unless preconditions_met?(options)
92
92
 
93
93
  @started = true
94
94
 
@@ -37,6 +37,7 @@ module ScoutApm
37
37
  :database_engine => ScoutApm::Environment.instance.database_engine,
38
38
  :application_name => ScoutApm::Environment.instance.application_name,
39
39
  :libraries => ScoutApm::Utils::InstalledGems.new.run,
40
+ :paas => ScoutApm::Environment.instance.pass
40
41
  }
41
42
  end
42
43
  end
@@ -21,6 +21,7 @@ module ScoutApm
21
21
  DEFAULTS = {
22
22
  'host' => 'https://checkin.scoutapp.com',
23
23
  'log_level' => 'info',
24
+ 'hostname' => Socket.gethostname,
24
25
  'stackprof_interval' => 20000 # microseconds, 1000 = 1 millisecond, so 20k == 20 milliseconds
25
26
  }.freeze
26
27
 
@@ -92,8 +92,20 @@ module ScoutApm
92
92
  ENV['DYNO']
93
93
  end
94
94
 
95
+ def cloud_foundry?
96
+ ENV['VCAP_APPLICATION']
97
+ end
98
+
99
+ def paas
100
+ if heroku?
101
+ 'Heroku'
102
+ elsif cloud_foundry?
103
+ 'Cloud Foundry'
104
+ end
105
+ end
106
+
95
107
  def hostname
96
- @hostname ||= heroku? ? ENV['DYNO'] : Socket.gethostname
108
+ @hostname ||= heroku? ? ENV['DYNO'] : Agent.instance.config.value("hostname")
97
109
  end
98
110
 
99
111
 
@@ -102,8 +114,9 @@ module ScoutApm
102
114
  # ever is checked first becomes the designated app server.
103
115
  #
104
116
  # Next step: (1) list out all detected app servers (2) install hooks for those that need it (passenger, rainbows, unicorn).
105
- def app_server_integration
106
- @app_server = SERVER_INTEGRATIONS.detect{ |integration| integration.present? }
117
+ def app_server_integration(force=false)
118
+ @app_server = nil if force
119
+ @app_server ||= SERVER_INTEGRATIONS.detect{ |integration| integration.present? }
107
120
  end
108
121
 
109
122
  # App server's name (symbol)
@@ -0,0 +1,16 @@
1
+ module ScoutApm
2
+ class Middleware
3
+ def initialize(app)
4
+ @app = app
5
+ @started = false
6
+ end
7
+
8
+ # If we get a web request in, then we know we're running in some sort of app server
9
+ def call(env)
10
+ ScoutApm::Agent.instance.start(:skip_app_server_check => true) unless @started
11
+
12
+ @started = true
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
@@ -27,3 +27,5 @@ module ScoutApm
27
27
  end
28
28
  end
29
29
  end
30
+
31
+
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.7.pre"
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: 0.9.6
4
+ version: 0.9.7.pre
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: 2015-10-28 00:00:00.000000000 Z
12
+ date: 2015-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -97,6 +97,7 @@ files:
97
97
  - lib/scout_apm/layaway_file.rb
98
98
  - lib/scout_apm/metric_meta.rb
99
99
  - lib/scout_apm/metric_stats.rb
100
+ - lib/scout_apm/middleware.rb
100
101
  - lib/scout_apm/reporter.rb
101
102
  - lib/scout_apm/serializers/app_server_load_serializer.rb
102
103
  - lib/scout_apm/serializers/deploy_serializer.rb
@@ -145,14 +146,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
146
  version: '0'
146
147
  required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  requirements:
148
- - - ">="
149
+ - - ">"
149
150
  - !ruby/object:Gem::Version
150
- version: '0'
151
+ version: 1.3.1
151
152
  requirements: []
152
153
  rubyforge_project: scout_apm
153
- rubygems_version: 2.2.2
154
+ rubygems_version: 2.4.8
154
155
  signing_key:
155
156
  specification_version: 4
156
157
  summary: Ruby application performance monitoring
157
- test_files: []
158
- has_rdoc:
158
+ test_files:
159
+ - test/data/config_test_1.yml
160
+ - test/test_helper.rb
161
+ - test/unit/config_test.rb
162
+ - test/unit/environment_test.rb
163
+ - test/unit/instruments/active_record_instruments_test.rb
164
+ - test/unit/sql_sanitizer_test.rb