scout_apm 1.4.4 → 1.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: 3f23c7ac5d4eb5fd3377ec8d9c4aa9f57a5fc356
4
- data.tar.gz: 72c4e84ceeae582c401e30343c0f0594c79036cc
3
+ metadata.gz: 32c7de1b69ce4dfb33779efa5ac201c95d155cf7
4
+ data.tar.gz: 9179a6163ebe2a3277d589fc9e20a77d715b17e5
5
5
  SHA512:
6
- metadata.gz: 7ae0882e14379a6a1d87923f20500fa9508cc8e63438788db0d9ee98ae773413a2f3a3d1aef9fee9977447cda1f10593f91de92837b8ee168e7a18c058b023ab
7
- data.tar.gz: 93197ba1fdf634b6ccf399ba1e73363abc21d0604ae71f75537f5280e50480855c280b4f11690be2c32d8e780a85011d5f8ac3f49fe6e256a138c7b71c9e5ea6
6
+ metadata.gz: 85f3023eec77d1884e7beebf3d1d2a08ac0126405c25db4fa3533edd90d40ce4439a6f87029ae5922f4db1063a4a14765b16e4bc9e92a2698423c2556d479321
7
+ data.tar.gz: a2c3ba865dff42734b1cf6dd7a712ff102e948f53a0f7087fb29be6bca8505d48b7aa73f1b39d7d84685b594c50df52aff1518eb8f8553d893172b52f95b3a42
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.4.5
2
+
3
+ * Instrument Elasticsearch
4
+ * Instrument InfluxDB
5
+
1
6
  # 1.4.4
2
7
 
3
8
  * Instrument Mongoid
data/lib/scout_apm.rb CHANGED
@@ -63,6 +63,8 @@ require 'scout_apm/instruments/http_client'
63
63
  require 'scout_apm/instruments/moped'
64
64
  require 'scout_apm/instruments/mongoid'
65
65
  require 'scout_apm/instruments/redis'
66
+ require 'scout_apm/instruments/influxdb'
67
+ require 'scout_apm/instruments/elasticsearch'
66
68
  require 'scout_apm/instruments/delayed_job'
67
69
  require 'scout_apm/instruments/active_record'
68
70
  require 'scout_apm/instruments/action_controller_rails_2'
@@ -254,6 +254,8 @@ module ScoutApm
254
254
  install_instrument(ScoutApm::Instruments::NetHttp)
255
255
  install_instrument(ScoutApm::Instruments::HttpClient)
256
256
  install_instrument(ScoutApm::Instruments::Redis)
257
+ install_instrument(ScoutApm::Instruments::InfluxDB)
258
+ install_instrument(ScoutApm::Instruments::Elasticsearch)
257
259
 
258
260
  if StackProf.respond_to?(:fake?) && StackProf.fake?
259
261
  logger.info 'StackProf not found - add `gem "stackprof"` to your Gemfile to enable advanced code profiling (only for Ruby 2.1+)'
@@ -0,0 +1,77 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class Elasticsearch
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?(::Elasticsearch) &&
19
+ defined?(::Elasticsearch::Transport) &&
20
+ defined?(::Elasticsearch::Transport::Client)
21
+
22
+ ScoutApm::Agent.instance.logger.info "Instrumenting Elasticsearch"
23
+
24
+ ::Elasticsearch::Transport::Client.class_eval do
25
+ include ScoutApm::Tracer
26
+
27
+ def perform_request_with_scout_instruments(*args, &block)
28
+ name = _sanitize_name(args[1])
29
+
30
+ self.class.instrument("Elasticsearch", name, :ignore_children => true) do
31
+ perform_request_without_scout_instruments(*args, &block)
32
+ end
33
+ end
34
+
35
+ alias_method :perform_request_without_scout_instruments, :perform_request
36
+ alias_method :perform_request, :perform_request_with_scout_instruments
37
+
38
+ def _sanitize_name(name)
39
+ name = name.split("/").last.gsub(/^_/, '')
40
+ allowed_names = ["bench",
41
+ "bulk",
42
+ "count",
43
+ "exists",
44
+ "explain",
45
+ "field_stats",
46
+ "health",
47
+ "mget",
48
+ "mlt",
49
+ "mpercolate",
50
+ "msearch",
51
+ "mtermvectors",
52
+ "percolate",
53
+ "query",
54
+ "scroll",
55
+ "search_shards",
56
+ "source",
57
+ "suggest",
58
+ "template",
59
+ "termvectors",
60
+ "update",
61
+ "search", ]
62
+
63
+ if allowed_names.include?(name)
64
+ name
65
+ else
66
+ "Unknown"
67
+ end
68
+ rescue
69
+ "Unknown"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+
@@ -0,0 +1,45 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class InfluxDB
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?(::InfluxDB)
19
+ ScoutApm::Agent.instance.logger.debug "Instrumenting InfluxDB"
20
+
21
+ ::InfluxDB::Client.class_eval do
22
+ include ScoutApm::Tracer
23
+ end
24
+
25
+ ::InfluxDB::HTTP.module_eval do
26
+ def do_request_with_scout_instruments(http, req, data = nil)
27
+ params = req.path[1..-1].split("?").last
28
+ cleaned_params = CGI.unescape(params).gsub(/(\s{2,})/,' ')
29
+
30
+ self.class.instrument("InfluxDB",
31
+ "#{req.path[1..-1].split("?").first.capitalize}",
32
+ :desc => cleaned_params,
33
+ :ignore_children => true) do
34
+ do_request_without_scout_instruments(http, req, data)
35
+ end
36
+ end
37
+
38
+ alias_method :do_request_without_scout_instruments, :do_request
39
+ alias_method :do_request, :do_request_with_scout_instruments
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -34,8 +34,8 @@ module ScoutApm
34
34
  begin
35
35
  yield
36
36
  ensure
37
- req.stop_layer
38
37
  req.acknowledge_children! if options[:ignore_children]
38
+ req.stop_layer
39
39
  end
40
40
  end
41
41
 
@@ -40,14 +40,20 @@ module ScoutApm
40
40
  end
41
41
 
42
42
  def start_layer(layer)
43
+ if ignoring_children?
44
+ ScoutApm::Agent.instance.logger.info("Skipping layer because we're ignoring children: #{layer.inspect}")
45
+ return
46
+ end
47
+
43
48
  start_request(layer) unless @root_layer
44
49
 
45
- # ScoutApm::Agent.instance.logger.info("Starting Layer: #{layer.to_s}")
46
50
  @layers[-1].add_child(layer) if @layers.any?
47
51
  @layers.push(layer)
48
52
  end
49
53
 
50
54
  def stop_layer
55
+ return if ignoring_children?
56
+
51
57
  layer = @layers.pop
52
58
  layer.record_stop_time!
53
59
 
@@ -160,6 +166,9 @@ module ScoutApm
160
166
  # internally
161
167
  #
162
168
  # When enabled, new layers won't be added to the current Request.
169
+ #
170
+ # Do not forget to turn if off when leaving a layer, it is the
171
+ # instrumentation's task to do that.
163
172
 
164
173
  def ignore_children!
165
174
  @ignoring_children = true
@@ -168,5 +177,9 @@ module ScoutApm
168
177
  def acknowledge_children!
169
178
  @ignoring_children = false
170
179
  end
180
+
181
+ def ignoring_children?
182
+ @ignoring_children
183
+ end
171
184
  end
172
185
  end
@@ -1,4 +1,4 @@
1
1
  module ScoutApm
2
- VERSION = "1.4.4"
2
+ VERSION = "1.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: 1.4.4
4
+ version: 1.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: 2016-03-22 00:00:00.000000000 Z
12
+ date: 2016-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -92,7 +92,9 @@ files:
92
92
  - lib/scout_apm/instruments/action_controller_rails_3_rails4.rb
93
93
  - lib/scout_apm/instruments/active_record.rb
94
94
  - lib/scout_apm/instruments/delayed_job.rb
95
+ - lib/scout_apm/instruments/elasticsearch.rb
95
96
  - lib/scout_apm/instruments/http_client.rb
97
+ - lib/scout_apm/instruments/influxdb.rb
96
98
  - lib/scout_apm/instruments/middleware_detailed.rb
97
99
  - lib/scout_apm/instruments/middleware_summary.rb
98
100
  - lib/scout_apm/instruments/mongoid.rb