scout_apm 1.6.3 → 1.6.4

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: 4e481167b7a01f99085ecca7253e31993282f410
4
- data.tar.gz: 745e06449927e08332c7fefe0258e516b8a84032
3
+ metadata.gz: b4a68db2ae2d5615f89aacc3c015909ee24bc49f
4
+ data.tar.gz: e21486b451e768a573c10615042c9b2d183bbb47
5
5
  SHA512:
6
- metadata.gz: 0fa9edba8ea58d71e7d7a65a83861edfd2674eb074c0dd0ef4db00739ebeb904a0fcde29159f541331eba7c4628a52048c14d60f4abb279ab641427f928f3f14
7
- data.tar.gz: 499cb503dcc1cbc3861698f62bbae753778b32f036a1824e8e37be18e68f7660e455904c4baf16023643c3545a1716f8e0e086b773d48499e2d01c7a1beadc35
6
+ metadata.gz: b6c77fd02eb44509a79f883e27ff4e306e6c96cf063481a617968d0e3b5bd8d6ad9125b3b39247879dfa3c0daba032a48f74c2ddce392fa87864d45aae5a35dd
7
+ data.tar.gz: feaf556828e488ebc3c15d951af248ede825af9b2a47b8a13428da6516e4ae377c672564e1594c42370368f784b0d68f2b4eff4d1d82d152a6ad5206d0122a0e
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.6.4
2
+
3
+ * Add Grape instrumentation
4
+ * Handle DATABASE_URL configurations better
5
+ * Change default (undeteced) database to Postgres (was Mysql)
6
+
1
7
  # 1.6.3
2
8
 
3
9
  * Handle nil ignore_traces when ignoring trace patterns
data/lib/scout_apm.rb CHANGED
@@ -77,6 +77,7 @@ require 'scout_apm/instruments/action_controller_rails_3_rails4'
77
77
  require 'scout_apm/instruments/middleware_summary'
78
78
  # require 'scout_apm/instruments/middleware_detailed' # Currently disabled functionality, see the file for details.
79
79
  require 'scout_apm/instruments/rails_router'
80
+ require 'scout_apm/instruments/grape'
80
81
  require 'scout_apm/instruments/sinatra'
81
82
  require 'scout_apm/instruments/process/process_cpu'
82
83
  require 'scout_apm/instruments/process/process_memory'
@@ -272,6 +272,7 @@ module ScoutApm
272
272
  install_instrument(ScoutApm::Instruments::Redis)
273
273
  install_instrument(ScoutApm::Instruments::InfluxDB)
274
274
  install_instrument(ScoutApm::Instruments::Elasticsearch)
275
+ install_instrument(ScoutApm::Instruments::Grape)
275
276
  rescue
276
277
  logger.warn "Exception loading instruments:"
277
278
  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
+
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "1.6.3"
2
+ VERSION = "1.6.4"
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: 1.6.3
4
+ version: 1.6.4
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-06-30 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: minitest
@@ -111,6 +111,7 @@ files:
111
111
  - lib/scout_apm/instruments/active_record.rb
112
112
  - lib/scout_apm/instruments/delayed_job.rb
113
113
  - lib/scout_apm/instruments/elasticsearch.rb
114
+ - lib/scout_apm/instruments/grape.rb
114
115
  - lib/scout_apm/instruments/http_client.rb
115
116
  - lib/scout_apm/instruments/influxdb.rb
116
117
  - lib/scout_apm/instruments/middleware_detailed.rb
@@ -199,7 +200,8 @@ files:
199
200
  - test/unit/sql_sanitizer_test.rb
200
201
  - test/unit/utils/active_record_metric_name_test.rb
201
202
  homepage: https://github.com/scoutapp/scout_apm_ruby
202
- licenses: []
203
+ licenses:
204
+ - Proprietary (See LICENSE.md)
203
205
  metadata: {}
204
206
  post_install_message:
205
207
  rdoc_options: []
@@ -218,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
220
  version: '0'
219
221
  requirements: []
220
222
  rubyforge_project: scout_apm
221
- rubygems_version: 2.4.6
223
+ rubygems_version: 2.6.2
222
224
  signing_key:
223
225
  specification_version: 4
224
226
  summary: Ruby application performance monitoring
@@ -239,3 +241,4 @@ test_files:
239
241
  - test/unit/slow_request_policy_test.rb
240
242
  - test/unit/sql_sanitizer_test.rb
241
243
  - test/unit/utils/active_record_metric_name_test.rb
244
+ has_rdoc: