scout_apm 2.5.2 → 2.5.3

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: c8715d4d303e068a7730e2ec2f788ee44c2bbd6762a3a3bd30cdcc9f167435b9
4
- data.tar.gz: 58e17c6491c144b596a61501b01406b15da245b6ce517a7fdbcaddfa896b0929
3
+ metadata.gz: ef6a530f826be85aee200f178152090c96dc8f2bab731c0f5220fa95a4662f56
4
+ data.tar.gz: e8ab6688fec666ff02c76a996dff3daf84fa1ca84be19b2666ba13b256f9fa92
5
5
  SHA512:
6
- metadata.gz: da8ddf5b4bb2a6d2223b49c1071dad0dd966234f2ed7b2e05747c67a0e3a9368b3831ef0496f5e6b57bd785ef486d12aade25db6815c2bf9a78ce1fce5f2acdf
7
- data.tar.gz: 9fc04fcf1fa8350b1c95b00c936612a6dfc575905f22821d86e4fa01474c3cd9eab1343857ece2d7cd7e631b625c4e7e4f2e24dc895068f59f08c7fbe0e777c2
6
+ metadata.gz: 4b8d53395a108407d445d1c386c1234ddbfa90e7105249ce357d288b92c5c9727a9c110a6e3510a111b6a4a9788f5e5f3a3eaedc532683cecbc09a8261c2f572
7
+ data.tar.gz: 3a35a76ed54a96df86948ad486d5a86a9dffed67271c5efae229b80a8106c00eb3830be469875cd301f7a262fba34672a8db52a25d4e82cba5105ce80af26dde
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ dist: trusty
2
3
  cache: bundler
3
4
 
4
5
  matrix:
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.5.3
2
+
3
+ * Add Que support (#265)
4
+
1
5
  # 2.5.2
2
6
 
3
7
  * Don't process limited layers in detailed traces (#268)
data/lib/scout_apm.rb CHANGED
@@ -62,6 +62,7 @@ require 'scout_apm/background_job_integrations/delayed_job'
62
62
  require 'scout_apm/background_job_integrations/resque'
63
63
  require 'scout_apm/background_job_integrations/shoryuken'
64
64
  require 'scout_apm/background_job_integrations/sneakers'
65
+ require 'scout_apm/background_job_integrations/que'
65
66
 
66
67
  require 'scout_apm/framework_integrations/rails_2'
67
68
  require 'scout_apm/framework_integrations/rails_3_or_4'
@@ -78,6 +79,7 @@ require 'scout_apm/instruments/net_http'
78
79
  require 'scout_apm/instruments/http_client'
79
80
  require 'scout_apm/instruments/moped'
80
81
  require 'scout_apm/instruments/mongoid'
82
+ require 'scout_apm/instruments/memcached'
81
83
  require 'scout_apm/instruments/redis'
82
84
  require 'scout_apm/instruments/influxdb'
83
85
  require 'scout_apm/instruments/elasticsearch'
@@ -0,0 +1,134 @@
1
+ module ScoutApm
2
+ module BackgroundJobIntegrations
3
+ class Que
4
+
5
+ UNKNOWN_CLASS_PLACEHOLDER = 'UnknownJob'.freeze
6
+ ACTIVE_JOB_KLASS = 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper'.freeze
7
+ UNKNOWN_QUEUE_PLACEHOLDER = 'UnknownQueue'.freeze
8
+
9
+ attr_reader :logger
10
+
11
+ def name
12
+ :que
13
+ end
14
+
15
+ def present?
16
+ if defined?(::Que) && File.basename($PROGRAM_NAME).start_with?('que')
17
+ # 0.x releases used "Version" constant.
18
+ # 1.x releases used "VERSION" constant.
19
+ return defined?(::Que::Version)
20
+ end
21
+ end
22
+
23
+ def forking?
24
+ false
25
+ end
26
+
27
+ def install
28
+ install_tracer
29
+ install_worker
30
+ install_job
31
+ end
32
+
33
+ def install_tracer
34
+ ::Que::Job.class_eval do
35
+ include ScoutApm::Tracer
36
+ end
37
+ end
38
+
39
+ def install_worker
40
+ ::Que::Worker.class_eval do
41
+ def initialize_with_scout(*args)
42
+ agent = ::ScoutApm::Agent.instance
43
+ agent.start
44
+ initialize_without_scout(*args)
45
+ end
46
+
47
+ alias_method :initialize_without_scout, :initialize
48
+ alias_method :initialize, :initialize_with_scout
49
+ end
50
+ end
51
+
52
+ def install_job
53
+ ::Que::Job.class_eval do
54
+ # attrs = {
55
+ # "queue"=>"",
56
+ # "priority"=>100,
57
+ # "run_at"=>2018-12-19 15:12:32 -0700,
58
+ # "job_id"=>4,
59
+ # "job_class"=>"ExampleJob",
60
+ # "args"=>[{"key"=>"value"}],
61
+ # "error_count"=>0
62
+ # }
63
+ #
64
+ # With ActiveJob, v0.14.3:
65
+ # attrs = {
66
+ # "queue"=>"",
67
+ # "priority"=>100,
68
+ # "run_at"=>2018-12-19 15:29:18 -0700,
69
+ # "job_id"=>6,
70
+ # "job_class"=>"ActiveJob::QueueAdapters::QueAdapter::JobWrapper",
71
+ # "args"=> [{
72
+ # "job_class"=>"ExampleJob",
73
+ # "job_id"=>"60798b45-4b55-436e-806d-693939266c97",
74
+ # "provider_job_id"=>nil,
75
+ # "queue_name"=>"default",
76
+ # "priority"=>nil,
77
+ # "arguments"=>[],
78
+ # "executions"=>0,
79
+ # "locale"=>"en"
80
+ # }],
81
+ # "error_count"=>0
82
+ # }
83
+ #
84
+ # With ActiveJob, v1.0:
85
+ # There are changes here to make Que more compatible with ActiveJob
86
+ # and this probably needs to be revisited.
87
+
88
+ def _run_with_scout(*args)
89
+ # default queue unless specifed is a blank string
90
+ queue = attrs['queue'] || UNKNOWN_QUEUE_PLACEHOLDER
91
+
92
+ job_class = begin
93
+ if self.class == ActiveJob::QueueAdapters::QueAdapter::JobWrapper
94
+ Array(attrs['args']).first['job_class'] || UNKNOWN_CLASS_PLACEHOLDER
95
+ else
96
+ self.class.name
97
+ end
98
+ rescue => e
99
+ UNKNOWN_CLASS_PLACEHOLDER
100
+ end
101
+
102
+ latency = begin
103
+ Time.now - attrs['run_at']
104
+ rescue
105
+ 0
106
+ end
107
+
108
+ req = ScoutApm::RequestManager.lookup
109
+ req.annotate_request(:queue_latency => latency)
110
+
111
+ begin
112
+ req.start_layer(ScoutApm::Layer.new('Queue', queue))
113
+ started_queue = true
114
+ req.start_layer(ScoutApm::Layer.new('Job', job_class))
115
+ started_job = true
116
+
117
+ _run_without_scout(*args)
118
+ rescue Exception => e
119
+ req.error!
120
+ raise
121
+ ensure
122
+ req.stop_layer if started_job
123
+ req.stop_layer if started_queue
124
+ end
125
+ end
126
+
127
+ alias_method :_run_without_scout, :_run
128
+ alias_method :_run, :_run_with_scout
129
+ end
130
+ end
131
+ end
132
+
133
+ end
134
+ end
@@ -29,6 +29,7 @@ module ScoutApm
29
29
  ScoutApm::BackgroundJobIntegrations::Shoryuken.new,
30
30
  ScoutApm::BackgroundJobIntegrations::Sneakers.new,
31
31
  ScoutApm::BackgroundJobIntegrations::DelayedJob.new,
32
+ ScoutApm::BackgroundJobIntegrations::Que.new,
32
33
  ]
33
34
 
34
35
  FRAMEWORK_INTEGRATIONS = [
@@ -31,6 +31,7 @@ module ScoutApm
31
31
  install_instrument(ScoutApm::Instruments::Mongoid)
32
32
  install_instrument(ScoutApm::Instruments::NetHttp)
33
33
  install_instrument(ScoutApm::Instruments::HttpClient)
34
+ install_instrument(ScoutApm::Instruments::Memcached)
34
35
  install_instrument(ScoutApm::Instruments::Redis)
35
36
  install_instrument(ScoutApm::Instruments::InfluxDB)
36
37
  install_instrument(ScoutApm::Instruments::Elasticsearch)
@@ -0,0 +1,43 @@
1
+ module ScoutApm
2
+ module Instruments
3
+ class Memcached
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?(::Dalli) && defined?(::Dalli::Client)
21
+ @installed = true
22
+
23
+ logger.info "Instrumenting Memcached"
24
+
25
+ ::Dalli::Client.class_eval do
26
+ include ScoutApm::Tracer
27
+
28
+ def perform_with_scout_instruments(*args, &block)
29
+ command = args.first rescue "Unknown"
30
+
31
+ self.class.instrument("Memcached", command) do
32
+ perform_without_scout_instruments(*args, &block)
33
+ end
34
+ end
35
+
36
+ alias_method :perform_without_scout_instruments, :perform
37
+ alias_method :perform, :perform_with_scout_instruments
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module ScoutApm
2
- VERSION = "2.5.2"
2
+ VERSION = "2.5.3"
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: 2.5.2
4
+ version: 2.5.3
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: 2019-08-13 00:00:00.000000000 Z
12
+ date: 2019-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -231,6 +231,7 @@ files:
231
231
  - lib/scout_apm/app_server_load.rb
232
232
  - lib/scout_apm/attribute_arranger.rb
233
233
  - lib/scout_apm/background_job_integrations/delayed_job.rb
234
+ - lib/scout_apm/background_job_integrations/que.rb
234
235
  - lib/scout_apm/background_job_integrations/resque.rb
235
236
  - lib/scout_apm/background_job_integrations/shoryuken.rb
236
237
  - lib/scout_apm/background_job_integrations/sidekiq.rb
@@ -269,6 +270,7 @@ files:
269
270
  - lib/scout_apm/instruments/grape.rb
270
271
  - lib/scout_apm/instruments/http_client.rb
271
272
  - lib/scout_apm/instruments/influxdb.rb
273
+ - lib/scout_apm/instruments/memcached.rb
272
274
  - lib/scout_apm/instruments/middleware_detailed.rb
273
275
  - lib/scout_apm/instruments/middleware_summary.rb
274
276
  - lib/scout_apm/instruments/mongoid.rb
@@ -428,9 +430,52 @@ required_rubygems_version: !ruby/object:Gem::Requirement
428
430
  - !ruby/object:Gem::Version
429
431
  version: '0'
430
432
  requirements: []
431
- rubyforge_project: scout_apm
432
- rubygems_version: 2.7.6
433
+ rubygems_version: 3.0.4
433
434
  signing_key:
434
435
  specification_version: 4
435
436
  summary: Ruby application performance monitoring
436
- test_files: []
437
+ test_files:
438
+ - test/data/config_test_1.yml
439
+ - test/test_helper.rb
440
+ - test/tmp/README.md
441
+ - test/unit/agent_test.rb
442
+ - test/unit/background_job_integrations/sidekiq_test.rb
443
+ - test/unit/config_test.rb
444
+ - test/unit/context_test.rb
445
+ - test/unit/db_query_metric_set_test.rb
446
+ - test/unit/db_query_metric_stats_test.rb
447
+ - test/unit/environment_test.rb
448
+ - test/unit/extensions/periodic_callbacks_test.rb
449
+ - test/unit/extensions/transaction_callbacks_test.rb
450
+ - test/unit/fake_store_test.rb
451
+ - test/unit/git_revision_test.rb
452
+ - test/unit/histogram_test.rb
453
+ - test/unit/ignored_uris_test.rb
454
+ - test/unit/instruments/active_record_test.rb
455
+ - test/unit/instruments/net_http_test.rb
456
+ - test/unit/instruments/percentile_sampler_test.rb
457
+ - test/unit/layaway_test.rb
458
+ - test/unit/layer_children_set_test.rb
459
+ - test/unit/layer_converters/depth_first_walker_test.rb
460
+ - test/unit/layer_converters/metric_converter_test.rb
461
+ - test/unit/layer_converters/stubs.rb
462
+ - test/unit/limited_layer_test.rb
463
+ - test/unit/logger_test.rb
464
+ - test/unit/metric_set_test.rb
465
+ - test/unit/remote/test_message.rb
466
+ - test/unit/remote/test_router.rb
467
+ - test/unit/remote/test_server.rb
468
+ - test/unit/scored_item_set_test.rb
469
+ - test/unit/serializers/payload_serializer_test.rb
470
+ - test/unit/slow_job_policy_test.rb
471
+ - test/unit/slow_request_policy_test.rb
472
+ - test/unit/sql_sanitizer_test.rb
473
+ - test/unit/store_test.rb
474
+ - test/unit/tracer_test.rb
475
+ - test/unit/tracked_request_test.rb
476
+ - test/unit/transaction_test.rb
477
+ - test/unit/transaction_time_consumed_test.rb
478
+ - test/unit/utils/active_record_metric_name_test.rb
479
+ - test/unit/utils/backtrace_parser_test.rb
480
+ - test/unit/utils/numbers_test.rb
481
+ - test/unit/utils/scm.rb