traxor 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -14
- data/.rubocop.yml +12 -2
- data/.travis.yml +9 -2
- data/Appraisals +13 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +39 -25
- data/Guardfile +72 -0
- data/README.md +157 -5
- data/Rakefile +2 -0
- data/bin/_guard-core +29 -0
- data/bin/appraisal +29 -0
- data/bin/code_climate_reek +1 -1
- data/bin/console +1 -0
- data/bin/{lois → guard} +3 -3
- data/bin/rake +1 -1
- data/bin/reek +1 -1
- data/bin/rspec +1 -1
- data/bin/rubocop +1 -1
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/active_support_5_0.gemfile +7 -0
- data/gemfiles/active_support_5_0.gemfile.lock +252 -0
- data/gemfiles/active_support_5_1.gemfile +7 -0
- data/gemfiles/active_support_5_1.gemfile.lock +252 -0
- data/gemfiles/active_support_5_2.gemfile +7 -0
- data/gemfiles/active_support_5_2.gemfile.lock +252 -0
- data/lib/traxor/faraday.rb +21 -8
- data/lib/traxor/metric.rb +11 -5
- data/lib/traxor/rack/middleware/post.rb +2 -0
- data/lib/traxor/rack/middleware/pre.rb +36 -12
- data/lib/traxor/rack/middleware/queue_time.rb +6 -10
- data/lib/traxor/rack/middleware.rb +3 -0
- data/lib/traxor/rack.rb +2 -0
- data/lib/traxor/rails/action_controller.rb +44 -21
- data/lib/traxor/rails/action_mailer.rb +17 -4
- data/lib/traxor/rails/active_record.rb +42 -19
- data/lib/traxor/rails/engine.rb +40 -0
- data/lib/traxor/rails.rb +2 -33
- data/lib/traxor/sidekiq.rb +13 -11
- data/lib/traxor/tags.rb +3 -1
- data/lib/traxor/version.rb +3 -1
- data/lib/traxor.rb +6 -2
- data/traxor.gemspec +6 -6
- metadata +22 -38
data/lib/traxor/rails.rb
CHANGED
@@ -1,34 +1,3 @@
|
|
1
|
-
|
2
|
-
class Rails < ::Rails::Engine
|
3
|
-
initializer 'traxor.setup'.freeze do |app|
|
4
|
-
if ::Rails.env.development? || ::Rails.env.test?
|
5
|
-
Traxor.initialize_logger(::Rails.root.join('log'.freeze, 'traxor.log'.freeze))
|
6
|
-
end
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
|
9
|
-
app.config.middleware.insert 0, Traxor::Rack::Middleware::Pre
|
10
|
-
app.config.middleware.use Traxor::Rack::Middleware::Post
|
11
|
-
|
12
|
-
ActiveSupport.on_load :action_controller do
|
13
|
-
require 'traxor/rails/action_controller'
|
14
|
-
end
|
15
|
-
ActiveSupport.on_load :active_record do
|
16
|
-
require 'traxor/rails/active_record'
|
17
|
-
end
|
18
|
-
ActiveSupport.on_load :action_mailer do
|
19
|
-
require 'traxor/rails/action_mailer'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
config.before_configuration do
|
24
|
-
require 'traxor/faraday' if defined?(Faraday)
|
25
|
-
|
26
|
-
if defined?(Sidekiq)
|
27
|
-
require 'traxor/sidekiq'
|
28
|
-
::Sidekiq.server_middleware do |chain|
|
29
|
-
chain.add Traxor::Sidekiq
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
3
|
+
require 'traxor/rails/engine'
|
data/lib/traxor/sidekiq.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/benchmark'
|
2
4
|
|
3
5
|
module Traxor
|
4
6
|
class Sidekiq
|
7
|
+
DURATION_METRIC = 'sidekiq.worker.duration'
|
8
|
+
COUNT_METRIC = 'sidekiq.worker.count'
|
9
|
+
EXCEPTION_METRIC = 'sidekiq.worker.exception.count'
|
10
|
+
|
5
11
|
def call(worker, _job, queue)
|
6
|
-
tags = Traxor::Tags.sidekiq = {
|
7
|
-
sidekiq_worker: worker.class.name,
|
8
|
-
sidekiq_queue: queue
|
9
|
-
}
|
12
|
+
tags = Traxor::Tags.sidekiq = { sidekiq_worker: worker.class.name, sidekiq_queue: queue }
|
10
13
|
begin
|
11
|
-
time = Benchmark.ms
|
12
|
-
|
13
|
-
end
|
14
|
-
Metric.measure 'sidekiq.worker.duration'.freeze, "#{time.round(2)}ms", tags if time.positive?
|
15
|
-
Metric.count 'sidekiq.worker.count'.freeze, 1, tags
|
14
|
+
time = Benchmark.ms { yield }
|
15
|
+
Metric.measure DURATION_METRIC, "#{time.round(2)}ms", tags if time.positive?
|
16
16
|
rescue StandardError
|
17
|
-
Metric.count
|
17
|
+
Metric.count EXCEPTION_METRIC, 1, tags
|
18
18
|
raise
|
19
|
+
ensure
|
20
|
+
Metric.count COUNT_METRIC, 1, tags
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
data/lib/traxor/tags.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/module/attribute_accessors_per_thread'
|
2
4
|
|
3
5
|
module Traxor
|
@@ -5,7 +7,7 @@ module Traxor
|
|
5
7
|
thread_mattr_accessor :controller, :sidekiq
|
6
8
|
|
7
9
|
def self.all
|
8
|
-
(controller
|
10
|
+
Hash(controller).merge(Hash(sidekiq)).dup
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
data/lib/traxor/version.rb
CHANGED
data/lib/traxor.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'logger'
|
2
|
-
require '
|
4
|
+
require 'traxor/faraday' if defined?(Faraday)
|
3
5
|
require 'traxor/metric'
|
4
|
-
require 'traxor/
|
6
|
+
require 'traxor/rack' if defined?(Rack)
|
7
|
+
require 'traxor/rails' if defined?(Rails::Engine)
|
8
|
+
require 'traxor/sidekiq' if defined?(Sidekiq)
|
5
9
|
require 'traxor/tags'
|
6
10
|
require 'traxor/version'
|
7
11
|
|
data/traxor.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path('lib', __dir__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require 'traxor/version'
|
@@ -20,15 +22,14 @@ Gem::Specification.new do |spec|
|
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
23
|
spec.require_paths = ['lib']
|
22
24
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
25
|
+
spec.required_ruby_version = '>= 2.4'
|
24
26
|
|
25
|
-
spec.add_dependency 'activesupport'
|
26
|
-
spec.add_dependency 'rails', '>= 4.2'
|
27
|
+
spec.add_dependency 'activesupport', '>= 5.0'
|
27
28
|
|
29
|
+
spec.add_development_dependency 'appraisal'
|
28
30
|
spec.add_development_dependency 'bundler'
|
29
31
|
spec.add_development_dependency 'faraday'
|
30
|
-
spec.add_development_dependency '
|
31
|
-
spec.add_development_dependency 'pry'
|
32
|
+
spec.add_development_dependency 'guard-rspec'
|
32
33
|
spec.add_development_dependency 'pry-byebug'
|
33
34
|
spec.add_development_dependency 'rails'
|
34
35
|
spec.add_development_dependency 'rake'
|
@@ -36,7 +37,6 @@ Gem::Specification.new do |spec|
|
|
36
37
|
spec.add_development_dependency 'rspec'
|
37
38
|
spec.add_development_dependency 'rspec_junit_formatter'
|
38
39
|
spec.add_development_dependency 'rubocop'
|
39
|
-
spec.add_development_dependency 'rubocop-rspec'
|
40
40
|
spec.add_development_dependency 'sidekiq'
|
41
41
|
spec.add_development_dependency 'simplecov'
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traxor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Hansen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,30 +16,16 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4.2'
|
19
|
+
version: '5.0'
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
26
|
+
version: '5.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
28
|
+
name: appraisal
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
@@ -53,7 +39,7 @@ dependencies:
|
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: faraday
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -81,7 +67,7 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: guard-rspec
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
@@ -192,20 +178,6 @@ dependencies:
|
|
192
178
|
- - ">="
|
193
179
|
- !ruby/object:Gem::Version
|
194
180
|
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: rubocop-rspec
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
181
|
- !ruby/object:Gem::Dependency
|
210
182
|
name: sidekiq
|
211
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,18 +219,29 @@ files:
|
|
247
219
|
- ".rspec"
|
248
220
|
- ".rubocop.yml"
|
249
221
|
- ".travis.yml"
|
222
|
+
- Appraisals
|
250
223
|
- Gemfile
|
251
224
|
- Gemfile.lock
|
225
|
+
- Guardfile
|
252
226
|
- README.md
|
253
227
|
- Rakefile
|
228
|
+
- bin/_guard-core
|
229
|
+
- bin/appraisal
|
254
230
|
- bin/code_climate_reek
|
255
231
|
- bin/console
|
256
|
-
- bin/
|
232
|
+
- bin/guard
|
257
233
|
- bin/rake
|
258
234
|
- bin/reek
|
259
235
|
- bin/rspec
|
260
236
|
- bin/rubocop
|
261
237
|
- bin/setup
|
238
|
+
- gemfiles/.bundle/config
|
239
|
+
- gemfiles/active_support_5_0.gemfile
|
240
|
+
- gemfiles/active_support_5_0.gemfile.lock
|
241
|
+
- gemfiles/active_support_5_1.gemfile
|
242
|
+
- gemfiles/active_support_5_1.gemfile.lock
|
243
|
+
- gemfiles/active_support_5_2.gemfile
|
244
|
+
- gemfiles/active_support_5_2.gemfile.lock
|
262
245
|
- lib/traxor.rb
|
263
246
|
- lib/traxor/faraday.rb
|
264
247
|
- lib/traxor/metric.rb
|
@@ -271,6 +254,7 @@ files:
|
|
271
254
|
- lib/traxor/rails/action_controller.rb
|
272
255
|
- lib/traxor/rails/action_mailer.rb
|
273
256
|
- lib/traxor/rails/active_record.rb
|
257
|
+
- lib/traxor/rails/engine.rb
|
274
258
|
- lib/traxor/sidekiq.rb
|
275
259
|
- lib/traxor/tags.rb
|
276
260
|
- lib/traxor/version.rb
|
@@ -286,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
286
270
|
requirements:
|
287
271
|
- - ">="
|
288
272
|
- !ruby/object:Gem::Version
|
289
|
-
version: '2.
|
273
|
+
version: '2.4'
|
290
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
275
|
requirements:
|
292
276
|
- - ">="
|