scout_apm 2.0.0.pre6 → 2.0.0.pre7

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: 629d6c7e70f5046f27c34c596820d6c2301f7119
4
- data.tar.gz: d3ac77c6e67dcf4a2b011ac927e05989351dbcdc
3
+ metadata.gz: c342425ce84acb55c8b62c2674eb94ec618746e6
4
+ data.tar.gz: 64d5f991d966e16b108ab7e61737c4f6836958b2
5
5
  SHA512:
6
- metadata.gz: 684890528a259f0b6c50a5e1997c79bf1edbd3277221d14ae8551efc0ef08c3a59c1323a7124ac52214de7cf821b9de1a69a745076c969b371d88a3fc07668fb
7
- data.tar.gz: fec408cb81a6c50536a7c63069e73027b629926c4a32f549ad9789dac0475d19447ae53214945fd81a3ed627e7aa16a8ebafb178c1294675efbcbfc893b3622a
6
+ metadata.gz: fe0fc8bd013cb679a6eefcae6523fd7dd61023189550f4e2dd1d865328d6bfb40d04186496b3dd9184d02937e578fb8dee74e88028d2dc68d3ccbc40ab937256
7
+ data.tar.gz: 6fd06f39a67c1f44549cb06c31129866cdf37a9f442225ff469667a86bab9a495252a4c6ac5c93135a54293df4e886743cad20d49cad78ccd9921b9704b73fe7
data/CHANGELOG.markdown CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  # 2.0.0
3
2
 
4
3
  * Reporting object allocation metrics and mem delta with slow requests and jobs.
@@ -11,6 +10,16 @@
11
10
  * Remove unused & old references to Stackprof
12
11
  * Fixing exception on load if no config file is provided
13
12
 
13
+ # 1.6.4
14
+
15
+ * Add Grape instrumentation
16
+ * Handle DATABASE_URL configurations better
17
+ * Change default (undeteced) database to Postgres (was Mysql)
18
+
19
+ # 1.6.3
20
+
21
+ * Handle nil ignore_traces when ignoring trace patterns
22
+
14
23
  # 1.6.2
15
24
 
16
25
  * Use a more flexible approach to storing "Layaway Files" (the temporary data
data/lib/scout_apm.rb CHANGED
@@ -79,6 +79,7 @@ require 'scout_apm/instruments/action_controller_rails_3_rails4'
79
79
  require 'scout_apm/instruments/middleware_summary'
80
80
  # require 'scout_apm/instruments/middleware_detailed' # Currently disabled functionality, see the file for details.
81
81
  require 'scout_apm/instruments/rails_router'
82
+ require 'scout_apm/instruments/grape'
82
83
  require 'scout_apm/instruments/sinatra'
83
84
  require 'scout_apm/instruments/process/process_cpu'
84
85
  require 'scout_apm/instruments/process/process_memory'
@@ -291,6 +291,7 @@ module ScoutApm
291
291
  install_instrument(ScoutApm::Instruments::Redis)
292
292
  install_instrument(ScoutApm::Instruments::InfluxDB)
293
293
  install_instrument(ScoutApm::Instruments::Elasticsearch)
294
+ install_instrument(ScoutApm::Instruments::Grape)
294
295
  rescue
295
296
  logger.warn "Exception loading instruments:"
296
297
  logger.warn $!.message
@@ -34,7 +34,7 @@ module ScoutApm
34
34
 
35
35
  def database_engine
36
36
  return @database_engine if @database_engine
37
- default = :mysql
37
+ default = :postgres
38
38
 
39
39
  @database_engine = if defined?(ActiveRecord::Base)
40
40
  adapter = get_database_adapter # can be nil
@@ -54,10 +54,20 @@ module ScoutApm
54
54
  end
55
55
 
56
56
  def get_database_adapter
57
- ActiveRecord::Base.configurations[env]["adapter"]
57
+ adapter = if ActiveRecord::Base.respond_to?(:connection_config)
58
+ ActiveRecord::Base.connection_config[:adapter].to_s
59
+ else
60
+ nil
61
+ end
62
+
63
+ if adapter.nil?
64
+ adapter = ActiveRecord::Base.configurations[env]["adapter"]
65
+ end
66
+
67
+ return adapter
58
68
  rescue # this would throw an exception if ActiveRecord::Base is defined but no configuration exists.
59
69
  nil
60
70
  end
61
71
  end
62
72
  end
63
- end
73
+ end
@@ -0,0 +1,69 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class Grape
4
+ attr_reader :logger
5
+
6
+ def initalize(logger=ScoutApm::Agent.instance.logger)
7
+ @logger = logger
8
+ @installed = false
9
+ end
10
+
11
+ def installed?
12
+ @installed
13
+ end
14
+
15
+ def install
16
+ @installed = true
17
+
18
+ if defined?(::Grape) && defined?(::Grape::Endpoint)
19
+ ScoutApm::Agent.instance.logger.info "Instrumenting Grape::Endpoint"
20
+
21
+ ::Grape::Endpoint.class_eval do
22
+ include ScoutApm::Instruments::GrapeEndpointInstruments
23
+
24
+ alias run_without_scout_instruments run
25
+ alias run run_with_scout_instruments
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module GrapeEndpointInstruments
32
+ def run_with_scout_instruments
33
+ request = ::Grape::Request.new(env)
34
+ req = ScoutApm::RequestManager.lookup
35
+ path = ScoutApm::Agent.instance.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
36
+ req.annotate_request(:uri => path)
37
+
38
+ # IP Spoofing Protection can throw an exception, just move on w/o remote ip
39
+ req.context.add_user(:ip => request.ip) rescue nil
40
+
41
+ req.set_headers(request.headers)
42
+ req.web!
43
+
44
+ begin
45
+ name = ["Grape",
46
+ self.options[:method].first,
47
+ self.options[:for].to_s,
48
+ self.namespace.sub(%r{\A/}, ''), # removing leading slashes
49
+ self.options[:path].first,
50
+ ].compact.map{ |n| n.to_s }.join("/")
51
+ rescue => e
52
+ ScoutApm::Agent.instance.logger.info("Error getting Grape Endpoint Name. Error: #{e.message}. Options: #{self.options.inspect}")
53
+ name = "Grape/Unknown"
54
+ end
55
+
56
+ req.start_layer( ScoutApm::Layer.new("Controller", name) )
57
+ begin
58
+ run_without_scout_instruments
59
+ rescue
60
+ req.error!
61
+ raise
62
+ ensure
63
+ req.stop_layer
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
@@ -39,7 +39,7 @@ module ScoutApm
39
39
  allocation_metrics = {}
40
40
  end
41
41
 
42
- ScoutApm::Agent.instance.config.value("ignore_traces").each do |pattern|
42
+ (ScoutApm::Agent.instance.config.value("ignore_traces") || []).each do |pattern|
43
43
  if /#{pattern}/ =~ uri
44
44
  ScoutApm::Agent.instance.logger.debug("Skipped recording a trace for #{uri} due to `ignore_traces` pattern: #{pattern}")
45
45
  return nil
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "2.0.0.pre6"
2
+ VERSION = "2.0.0.pre7"
3
3
  end
4
4
 
data/scout_apm.gemspec CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "https://github.com/scoutapp/scout_apm_ruby"
11
11
  s.summary = "Ruby application performance monitoring"
12
12
  s.description = "Monitors Ruby apps and reports detailed metrics on performance to Scout."
13
+ s.license = "Proprietary (See LICENSE.md)"
13
14
 
14
15
  s.rubyforge_project = "scout_apm"
15
16
 
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.0.0.pre6
4
+ version: 2.0.0.pre7
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: 2016-07-03 00:00:00.000000000 Z
12
+ date: 2016-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rusage
@@ -146,6 +146,7 @@ files:
146
146
  - lib/scout_apm/instruments/active_record.rb
147
147
  - lib/scout_apm/instruments/delayed_job.rb
148
148
  - lib/scout_apm/instruments/elasticsearch.rb
149
+ - lib/scout_apm/instruments/grape.rb
149
150
  - lib/scout_apm/instruments/http_client.rb
150
151
  - lib/scout_apm/instruments/influxdb.rb
151
152
  - lib/scout_apm/instruments/middleware_detailed.rb
@@ -236,7 +237,8 @@ files:
236
237
  - test/unit/sql_sanitizer_test.rb
237
238
  - test/unit/utils/active_record_metric_name_test.rb
238
239
  homepage: https://github.com/scoutapp/scout_apm_ruby
239
- licenses: []
240
+ licenses:
241
+ - Proprietary (See LICENSE.md)
240
242
  metadata: {}
241
243
  post_install_message:
242
244
  rdoc_options: []
@@ -255,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
257
  version: 1.3.1
256
258
  requirements: []
257
259
  rubyforge_project: scout_apm
258
- rubygems_version: 2.4.8
260
+ rubygems_version: 2.6.2
259
261
  signing_key:
260
262
  specification_version: 4
261
263
  summary: Ruby application performance monitoring