scout_apm 4.0.1 → 4.0.2

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
  SHA256:
3
- metadata.gz: 1cce8f36675013a0c19a8fcc9c989c3cdb9ce200dbd9d80910ba0f1581a69e6b
4
- data.tar.gz: adebeda03d35f00f36f0db73e78a205bd90646f6ab005270660cf7d86a4b685f
3
+ metadata.gz: 984d05544e5a2ce1b325c8a27f619f9b7ee54e8d98f614bebd41049c2c162105
4
+ data.tar.gz: f10c260c2cab2d1f00d6f6267eb643b860f872352edc9fa8ba8bedd0ac392023
5
5
  SHA512:
6
- metadata.gz: fc9fc58ab95c94e5d904bc3b04c5d0a37be1cecb965d88cf994a652e46542457d298759f0a8cfce4040def439d77970a04f35d258b2b96546354ef46b93da42e
7
- data.tar.gz: f1ab27e4646ccaa8a11220aff213d239b61434f2e511584e560c5234beec9b1746801a53898b49136097c814f726cf31b4d2dafbcaaf928910cd2204f51b5a84
6
+ metadata.gz: ec9bc8174b44664990ffd3ab52fa0b3232f8c000dd69b50cab3d69b467acd74138aaec8d7494ecb1ae4cd50c3a70709db11abe232a9636cb76bb497bbc70341a
7
+ data.tar.gz: 114715176bcfb080ad8db4cce5fc38d6e3de345e19899352e754dee042bbf6267c983fd8e0dba8a87cb9d6efd4e29af9a047d123c429cac7a86854125e961dc5
@@ -1,3 +1,7 @@
1
+ # 4.0.2
2
+
3
+ * Add Typhoeus instrumentation (#376)
4
+
1
5
  # 4.0.1
2
6
 
3
7
  * Add support for Ruby 3.0 (#374)
@@ -78,6 +78,7 @@ require 'scout_apm/histogram'
78
78
 
79
79
  require 'scout_apm/instruments/net_http'
80
80
  require 'scout_apm/instruments/http_client'
81
+ require 'scout_apm/instruments/typhoeus'
81
82
  require 'scout_apm/instruments/moped'
82
83
  require 'scout_apm/instruments/mongoid'
83
84
  require 'scout_apm/instruments/memcached'
@@ -30,6 +30,7 @@ module ScoutApm
30
30
  install_instrument(ScoutApm::Instruments::Moped)
31
31
  install_instrument(ScoutApm::Instruments::Mongoid)
32
32
  install_instrument(ScoutApm::Instruments::NetHttp)
33
+ install_instrument(ScoutApm::Instruments::Typhoeus)
33
34
  install_instrument(ScoutApm::Instruments::HttpClient)
34
35
  install_instrument(ScoutApm::Instruments::Memcached)
35
36
  install_instrument(ScoutApm::Instruments::Redis)
@@ -0,0 +1,87 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class Typhoeus
4
+ attr_reader :context
5
+
6
+ def initialize(context)
7
+ @context = context
8
+ @installed = false
9
+ end
10
+
11
+ def logger
12
+ context.logger
13
+ end
14
+
15
+ def installed?
16
+ @installed
17
+ end
18
+
19
+ def install
20
+ if defined?(::Typhoeus)
21
+ @installed = true
22
+
23
+ logger.info "Instrumenting Typhoeus"
24
+
25
+ ::Typhoeus::Request.send(:prepend, TyphoeusInstrumentation)
26
+ ::Typhoeus::Hydra.send(:prepend, TyphoeusHydraInstrumentation)
27
+ end
28
+ end
29
+
30
+ module TyphoeusHydraInstrumentation
31
+ def run(*args, &block)
32
+ req = ScoutApm::RequestManager.lookup
33
+ req.start_layer(ScoutApm::Layer.new("HTTP", "Hydra"))
34
+ req.current_layer.desc = scout_desc
35
+
36
+ begin
37
+ super(*args, &block)
38
+ ensure
39
+ req.stop_layer
40
+ end
41
+ end
42
+
43
+ def scout_desc
44
+ "#{self.queued_requests.count} requests"
45
+ rescue
46
+ ""
47
+ end
48
+ end
49
+
50
+ module TyphoeusInstrumentation
51
+ def run(*args, &block)
52
+ req = ScoutApm::RequestManager.lookup
53
+ req.start_layer(ScoutApm::Layer.new("HTTP", scout_request_verb))
54
+ req.current_layer.desc = scout_desc(scout_request_verb, scout_request_url)
55
+
56
+
57
+ begin
58
+ super(*args, &block)
59
+ ensure
60
+ req.stop_layer
61
+ end
62
+ end
63
+
64
+ def scout_desc(verb, uri)
65
+ max_length = ScoutApm::Agent.instance.context.config.value('instrument_http_url_length')
66
+ (String(uri).split('?').first)[0..(max_length - 1)]
67
+ rescue
68
+ ""
69
+ end
70
+
71
+ def scout_request_url
72
+ self.url
73
+ rescue
74
+ ""
75
+ end
76
+
77
+ def scout_request_verb
78
+ self.options[:method].to_s
79
+ rescue
80
+ ""
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.2"
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: 4.0.1
4
+ version: 4.0.2
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: 2021-01-18 00:00:00.000000000 Z
12
+ date: 2021-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -316,6 +316,7 @@ files:
316
316
  - lib/scout_apm/instruments/resque.rb
317
317
  - lib/scout_apm/instruments/samplers.rb
318
318
  - lib/scout_apm/instruments/sinatra.rb
319
+ - lib/scout_apm/instruments/typhoeus.rb
319
320
  - lib/scout_apm/job_record.rb
320
321
  - lib/scout_apm/layaway.rb
321
322
  - lib/scout_apm/layaway_file.rb
@@ -478,7 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
478
479
  - !ruby/object:Gem::Version
479
480
  version: '0'
480
481
  requirements: []
481
- rubygems_version: 3.1.2
482
+ rubygems_version: 3.0.8
482
483
  signing_key:
483
484
  specification_version: 4
484
485
  summary: Ruby application performance monitoring