nightwing 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +21 -1
- data/Gemfile.lock +15 -2
- data/LICENSE.txt +21 -0
- data/README.md +18 -2
- data/lib/nightwing/client_logger.rb +17 -0
- data/lib/nightwing/{nil_client.rb → debug_client.rb} +1 -1
- data/lib/nightwing/logger.rb +21 -0
- data/lib/nightwing/sidekiq/base.rb +17 -3
- data/lib/nightwing/sidekiq/profiler.rb +38 -0
- data/lib/nightwing/sidekiq/queue_stats.rb +2 -7
- data/lib/nightwing/sidekiq/stats.rb +2 -8
- data/lib/nightwing/sidekiq/worker_stats.rb +9 -8
- data/lib/nightwing/version.rb +1 -1
- data/lib/nightwing.rb +1 -0
- data/nightwing.gemspec +1 -0
- data/spec/nightwing/sidekiq/profiler_spec.rb +37 -0
- data/spec/nightwing/sidekiq/queue_stats_spec.rb +8 -8
- data/spec/nightwing/sidekiq/stats_spec.rb +8 -8
- data/spec/nightwing/sidekiq/worker_stats_spec.rb +19 -9
- data/spec/spec_helper.rb +2 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918b61571eb184206d03a99f762982658944339c
|
4
|
+
data.tar.gz: 1e3741e8078e80f055354d80de4fee4a311d72e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06dbfca4a437ba0df72dee941eb0847e5831629b1ca98270712a7bda6d4426c1c65ae3db7359171d2e8d0908687f2494ceb5b016e0ade49c5a4d888b5eda5452
|
7
|
+
data.tar.gz: 1dabeed4b2bfc8f07d514520acb3f50b39a61fae193c0950b8f3b141a475e501324e124a22cd36228397d9a6c77937f3b152350369e9d9bf71998bb7194ed9cf
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,24 @@
|
|
1
|
-
##
|
1
|
+
## 0.1.0
|
2
|
+
|
3
|
+
- Add new Profiler middleware
|
4
|
+
- Add a copy of the MIT license
|
5
|
+
- New debug mode
|
6
|
+
- Allow users to pass in their own logger object
|
7
|
+
|
8
|
+
**New Metrics**
|
9
|
+
|
10
|
+
In `Nightwing::Sidekiq::Profiler` middleware:
|
11
|
+
|
12
|
+
- `sidekiq.<queue>.<worker>.retried`
|
13
|
+
|
14
|
+
In `Nightwing::Sidekiq::Profiler` middleware:
|
15
|
+
|
16
|
+
- `sidekiq.<queue>.time`
|
17
|
+
- `sidekiq.<queue>.memory_used`
|
18
|
+
- `sidekiq.<queue>.gc.count`
|
19
|
+
- `sidekiq.<queue>.<worker>.time`
|
20
|
+
- `sidekiq.<queue>.<worker>.gc.count`
|
21
|
+
- `sidekiq.<queue>.<worker>.memory_used`
|
2
22
|
|
3
23
|
## 0.0.5
|
4
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nightwing (0.0
|
4
|
+
nightwing (0.1.0)
|
5
5
|
activesupport (>= 4.1.0)
|
6
|
+
oink (= 0.10.1)
|
6
7
|
sidekiq (>= 2.6)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
|
-
|
12
|
+
activemodel (4.2.5)
|
13
|
+
activesupport (= 4.2.5)
|
14
|
+
builder (~> 3.1)
|
15
|
+
activerecord (4.2.5)
|
16
|
+
activemodel (= 4.2.5)
|
17
|
+
activesupport (= 4.2.5)
|
18
|
+
arel (~> 6.0)
|
19
|
+
activesupport (4.2.5)
|
12
20
|
i18n (~> 0.7)
|
13
21
|
json (~> 1.7, >= 1.7.7)
|
14
22
|
minitest (~> 5.1)
|
15
23
|
thread_safe (~> 0.3, >= 0.3.4)
|
16
24
|
tzinfo (~> 1.1)
|
25
|
+
arel (6.0.3)
|
17
26
|
ast (2.2.0)
|
18
27
|
builder (3.2.2)
|
19
28
|
concurrent-ruby (1.0.0)
|
20
29
|
connection_pool (2.2.0)
|
21
30
|
diff-lcs (1.2.5)
|
31
|
+
hodel_3000_compliant_logger (0.1.1)
|
22
32
|
i18n (0.7.0)
|
23
33
|
json (1.8.3)
|
24
34
|
minitest (5.8.4)
|
35
|
+
oink (0.10.1)
|
36
|
+
activerecord
|
37
|
+
hodel_3000_compliant_logger
|
25
38
|
parser (2.3.0.2)
|
26
39
|
ast (~> 2.2)
|
27
40
|
powerpack (0.1.1)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Teespring, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -14,6 +14,8 @@ gem 'nightwing'
|
|
14
14
|
|
15
15
|
You will need to add the code below to your app. In a typical Rails app, this would go into an initializer.
|
16
16
|
|
17
|
+
Please note that you must require your own librato-rack gem and supply it to Nightwing
|
18
|
+
|
17
19
|
```ruby
|
18
20
|
# config/initializers/sidekiq.rb
|
19
21
|
Sidekiq.configure_server do |config|
|
@@ -21,14 +23,21 @@ Sidekiq.configure_server do |config|
|
|
21
23
|
chain.add Nightwing::Sidekiq::Stats, client: Librato
|
22
24
|
chain.add Nightwing::Sidekiq::QueueStats, client: Librato
|
23
25
|
chain.add Nightwing::Sidekiq::WorkerStats, client: Librato
|
26
|
+
chain.add Nightwing::Sidekiq::Profiler, client: Librato
|
24
27
|
end
|
25
28
|
end
|
26
29
|
```
|
27
30
|
|
28
31
|
### Available options
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
| Name | Description | Required? | Default |
|
34
|
+
|-----------|--------------------------------|-----------|-------------------|
|
35
|
+
| client | Librato or statsd client | yes | N/A |
|
36
|
+
| namespace | Prefix for each metric | no | "sidekiq" |
|
37
|
+
| debug | Enable for verbose logging | no | false |
|
38
|
+
| logger | Logger instance for debug mode | no | Nightwing::Logger |
|
39
|
+
|
40
|
+
When debug mode is turned on, Nightwing will output the metrics into a parsable format. The output destination is determined by the logger. If no logger is given then we send the debugging output to STDOUT.
|
32
41
|
|
33
42
|
## Metrics
|
34
43
|
|
@@ -45,6 +54,9 @@ Below are the metrics reported to Librato from the Sidekiq middleware
|
|
45
54
|
- `sidekiq.<queue>.latency`: latency for given queue¹
|
46
55
|
- `sidekiq.<queue>.processed`: number of times middleware called for given queue
|
47
56
|
- `sidekiq.<queue>.failed`: number of jobs in given queue that raised an error
|
57
|
+
- `sidekiq.<queue>.time`: how long jobs took to process (in milliseconds)
|
58
|
+
- `sidekiq.<queue>.gc.count`: number of times the Ruby GC kicked off
|
59
|
+
- `sidekiq.<queue>.memory_used`: the different in the process memory after jobs were processed (in bytes)
|
48
60
|
|
49
61
|
¹: the difference between now and when the oldest job was enqueued (given in seconds)
|
50
62
|
|
@@ -53,3 +65,7 @@ Below are the metrics reported to Librato from the Sidekiq middleware
|
|
53
65
|
- `sidekiq.<queue>.<worker>.processed`: number of times middleware called for given worker
|
54
66
|
- `sidekiq.<queue>.<worker>.failed`: number of jobs in given worker that raised an error
|
55
67
|
- `sidekiq.<queue>.<worker>.finished`: number of successful worker jobs
|
68
|
+
- `sidekiq.<queue>.<worker>.time`: how long given worker took to process (in milliseconds)
|
69
|
+
- `sidekiq.<queue>.<worker>.retried`: number of times a given worker retried
|
70
|
+
- `sidekiq.<queue>.<worker>.gc.count`: number of times the Ruby GC kicked off
|
71
|
+
- `sidekiq.<queue>.<worker>.memory_used`: the different in the process memory after jobs were processed (in bytes)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Nightwing
|
2
|
+
class ClientLogger
|
3
|
+
def initialize(client:, logger:)
|
4
|
+
@client = client
|
5
|
+
@logger = logger
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(method, *args, &block)
|
9
|
+
unless @client.respond_to?(method)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
@logger.info "method=#{method} metric=#{args[0]} value=#{args.last if args.size > 1}"
|
14
|
+
@client.public_send(method, *args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Nightwing
|
2
|
+
class Logger
|
3
|
+
def debug(msg)
|
4
|
+
print :debug, msg
|
5
|
+
end
|
6
|
+
|
7
|
+
def info(msg)
|
8
|
+
print :info, msg
|
9
|
+
end
|
10
|
+
|
11
|
+
def warn(msg)
|
12
|
+
print :warn, msg
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def print(level, msg)
|
18
|
+
puts "#{Time.now} nightwing.#{level}: #{msg}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,15 +1,29 @@
|
|
1
1
|
require "sidekiq/api"
|
2
2
|
require "nightwing/metric"
|
3
|
-
require "nightwing/
|
3
|
+
require "nightwing/debug_client"
|
4
|
+
require "nightwing/logger"
|
5
|
+
require "nightwing/client_logger"
|
4
6
|
|
5
7
|
module Nightwing
|
6
8
|
module Sidekiq
|
7
9
|
class Base
|
8
|
-
attr_reader :namespace, :
|
10
|
+
attr_reader :namespace, :logger
|
9
11
|
|
10
12
|
def initialize(options = {})
|
11
13
|
@namespace = options.fetch(:namespace, "sidekiq")
|
12
|
-
@client = options.fetch(:client, Nightwing::
|
14
|
+
@client = options.fetch(:client, Nightwing::DebugClient.new)
|
15
|
+
@logger = options.fetch(:logger, Nightwing::Logger.new)
|
16
|
+
@debug = options.fetch(:debug, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
def client
|
20
|
+
@client_proxy ||= begin
|
21
|
+
if @debug
|
22
|
+
Nightwing::ClientLogger.new(client: @client, logger: @logger)
|
23
|
+
else
|
24
|
+
@client
|
25
|
+
end
|
26
|
+
end
|
13
27
|
end
|
14
28
|
|
15
29
|
private
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "nightwing/sidekiq/profiler"
|
2
|
+
require "oink"
|
3
|
+
|
4
|
+
module Nightwing
|
5
|
+
module Sidekiq
|
6
|
+
class Profiler < Base
|
7
|
+
def call(worker, _msg, queue)
|
8
|
+
queue_namespace = metrics.for(queue: queue)
|
9
|
+
worker_namespace = metrics.for(queue: queue, worker: worker.class)
|
10
|
+
|
11
|
+
begin
|
12
|
+
started_at = Time.now
|
13
|
+
initial_gc_count = ::GC.count
|
14
|
+
initial_snapshot = memory_snapshot
|
15
|
+
|
16
|
+
yield
|
17
|
+
ensure
|
18
|
+
memory_delta_in_bytes = memory_snapshot - initial_snapshot
|
19
|
+
total_time = ((Time.now - started_at) * 1_000).round
|
20
|
+
total_gc_count = ::GC.count - initial_gc_count
|
21
|
+
|
22
|
+
client.timing "#{worker_namespace}.time", total_time
|
23
|
+
client.measure "#{worker_namespace}.memory_used", memory_delta_in_bytes
|
24
|
+
client.measure "#{worker_namespace}.gc.count", total_gc_count
|
25
|
+
|
26
|
+
client.timing "#{queue_namespace}.time", total_time
|
27
|
+
client.measure "#{queue_namespace}.memory_used", memory_delta_in_bytes
|
28
|
+
client.measure "#{queue_namespace}.gc.count", total_gc_count
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# returns number of bytes used by current process
|
33
|
+
def memory_snapshot
|
34
|
+
Oink::Instrumentation::MemorySnapshot.memory
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -17,7 +17,6 @@ module Nightwing
|
|
17
17
|
# @param [String] queue
|
18
18
|
# The current queue.
|
19
19
|
def call(_worker, _msg, queue)
|
20
|
-
exception = nil
|
21
20
|
sidekiq_queue = ::Sidekiq::Queue.new(queue)
|
22
21
|
queue_namespace = metrics.for(queue: queue)
|
23
22
|
|
@@ -27,13 +26,9 @@ module Nightwing
|
|
27
26
|
|
28
27
|
begin
|
29
28
|
yield
|
30
|
-
rescue
|
31
|
-
exception = e
|
32
|
-
end
|
33
|
-
|
34
|
-
if exception
|
29
|
+
rescue
|
35
30
|
client.increment "#{queue_namespace}.failed"
|
36
|
-
raise
|
31
|
+
raise
|
37
32
|
end
|
38
33
|
end
|
39
34
|
end
|
@@ -17,21 +17,15 @@ module Nightwing
|
|
17
17
|
# @param [String] _queue
|
18
18
|
# The current queue.
|
19
19
|
def call(_worker, _msg, _queue)
|
20
|
-
exception = nil
|
21
|
-
|
22
20
|
client.measure "#{namespace}.retries", retries.size
|
23
21
|
client.measure "#{namespace}.scheduled", scheduled.size
|
24
22
|
client.increment "#{namespace}.processed"
|
25
23
|
|
26
24
|
begin
|
27
25
|
yield
|
28
|
-
rescue
|
29
|
-
exception = e
|
30
|
-
end
|
31
|
-
|
32
|
-
if exception
|
26
|
+
rescue
|
33
27
|
client.increment "#{namespace}.failed"
|
34
|
-
raise
|
28
|
+
raise
|
35
29
|
end
|
36
30
|
end
|
37
31
|
|
@@ -3,21 +3,22 @@ require "nightwing/sidekiq/base"
|
|
3
3
|
module Nightwing
|
4
4
|
module Sidekiq
|
5
5
|
class WorkerStats < Base
|
6
|
-
def call(worker,
|
7
|
-
exception = nil
|
6
|
+
def call(worker, msg, queue)
|
8
7
|
worker_namespace = metrics.for(queue: queue, worker: worker.class)
|
9
8
|
|
10
9
|
client.increment "#{worker_namespace}.processed"
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
if msg["retry"]
|
12
|
+
if msg["retry_count"].to_i > 0
|
13
|
+
client.increment "#{worker_namespace}.retried"
|
14
|
+
end
|
16
15
|
end
|
17
16
|
|
18
|
-
|
17
|
+
begin
|
18
|
+
yield
|
19
|
+
rescue
|
19
20
|
client.increment "#{worker_namespace}.failed"
|
20
|
-
raise
|
21
|
+
raise
|
21
22
|
end
|
22
23
|
|
23
24
|
client.increment "#{worker_namespace}.finished"
|
data/lib/nightwing/version.rb
CHANGED
data/lib/nightwing.rb
CHANGED
data/nightwing.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_runtime_dependency "sidekiq", ">= 2.6"
|
16
16
|
s.add_runtime_dependency "activesupport", ">= 4.1.0"
|
17
|
+
s.add_runtime_dependency "oink", "0.10.1"
|
17
18
|
|
18
19
|
s.add_development_dependency "rubocop", "~> 0.36"
|
19
20
|
s.add_development_dependency "rspec", "~> 3.4", ">= 3.4.0"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Nightwing::Sidekiq::Profiler do
|
4
|
+
subject { Nightwing::Sidekiq::Profiler.new(client: Nightwing::DebugClient.new) }
|
5
|
+
|
6
|
+
let(:time_in_ms) { 55 }
|
7
|
+
let(:buffer) { 5 }
|
8
|
+
|
9
|
+
describe "#call" do
|
10
|
+
it "records time" do
|
11
|
+
expect(subject.client).to receive(:timing) do |*args|
|
12
|
+
expect(args.first).to eq("sidekiq.default.my_worker.time")
|
13
|
+
expect(args.last).to be_between(0, time_in_ms + buffer)
|
14
|
+
end
|
15
|
+
|
16
|
+
expect(subject.client).to receive(:timing) do |*args|
|
17
|
+
expect(args.first).to eq("sidekiq.default.time")
|
18
|
+
expect(args.last).to be_between(0, time_in_ms + buffer)
|
19
|
+
end
|
20
|
+
|
21
|
+
subject.call(MyWorker.new, nil, "default") do
|
22
|
+
sleep time_in_ms / 1_000 # sleep for ~55ms
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "records memory" do
|
27
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.my_worker.memory_used", 0).and_call_original
|
28
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.my_worker.gc.count", 0).and_call_original
|
29
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.memory_used", 0).and_call_original
|
30
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.gc.count", 0).and_call_original
|
31
|
+
|
32
|
+
subject.call(MyWorker.new, nil, "default") do
|
33
|
+
# beep
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Nightwing::Sidekiq::QueueStats do
|
4
|
-
subject { Nightwing::Sidekiq::QueueStats.new(client: Nightwing::
|
4
|
+
subject { Nightwing::Sidekiq::QueueStats.new(client: Nightwing::DebugClient.new) }
|
5
5
|
|
6
6
|
describe "#call" do
|
7
7
|
let(:fake_queue) { Struct.new(:size, :latency).new(0, 0) }
|
@@ -12,9 +12,9 @@ describe Nightwing::Sidekiq::QueueStats do
|
|
12
12
|
|
13
13
|
context "when everything just works" do
|
14
14
|
it "increments process count" do
|
15
|
-
expect(subject.client).to receive(:measure).with("sidekiq.default.size", 0)
|
16
|
-
expect(subject.client).to receive(:measure).with("sidekiq.default.latency", 0)
|
17
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.processed")
|
15
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.size", 0).and_call_original
|
16
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.latency", 0).and_call_original
|
17
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.processed").and_call_original
|
18
18
|
|
19
19
|
subject.call(nil, nil, "default") do
|
20
20
|
# beep
|
@@ -24,10 +24,10 @@ describe Nightwing::Sidekiq::QueueStats do
|
|
24
24
|
|
25
25
|
context "when something fails" do
|
26
26
|
it "increments process and failure count" do
|
27
|
-
expect(subject.client).to receive(:measure).with("sidekiq.default.size", 0)
|
28
|
-
expect(subject.client).to receive(:measure).with("sidekiq.default.latency", 0)
|
29
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.processed")
|
30
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.failed")
|
27
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.size", 0).and_call_original
|
28
|
+
expect(subject.client).to receive(:measure).with("sidekiq.default.latency", 0).and_call_original
|
29
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.processed").and_call_original
|
30
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.failed").and_call_original
|
31
31
|
|
32
32
|
expect do
|
33
33
|
subject.call(nil, nil, "default") do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Nightwing::Sidekiq::Stats do
|
4
|
-
subject { Nightwing::Sidekiq::Stats.new(client: Nightwing::
|
4
|
+
subject { Nightwing::Sidekiq::Stats.new(client: Nightwing::DebugClient.new) }
|
5
5
|
|
6
6
|
before do
|
7
7
|
fake_set = Struct.new(:size).new(1)
|
@@ -12,9 +12,9 @@ describe Nightwing::Sidekiq::Stats do
|
|
12
12
|
describe "#call" do
|
13
13
|
context "when everything just works" do
|
14
14
|
it "increments process count" do
|
15
|
-
expect(subject.client).to receive(:measure).with("sidekiq.retries", 1)
|
16
|
-
expect(subject.client).to receive(:measure).with("sidekiq.scheduled", 1)
|
17
|
-
expect(subject.client).to receive(:increment).with("sidekiq.processed")
|
15
|
+
expect(subject.client).to receive(:measure).with("sidekiq.retries", 1).and_call_original
|
16
|
+
expect(subject.client).to receive(:measure).with("sidekiq.scheduled", 1).and_call_original
|
17
|
+
expect(subject.client).to receive(:increment).with("sidekiq.processed").and_call_original
|
18
18
|
|
19
19
|
subject.call(nil, nil, nil) do
|
20
20
|
# beep
|
@@ -24,10 +24,10 @@ describe Nightwing::Sidekiq::Stats do
|
|
24
24
|
|
25
25
|
context "when something fails" do
|
26
26
|
it "increments process and failure count" do
|
27
|
-
expect(subject.client).to receive(:measure).with("sidekiq.retries", 1)
|
28
|
-
expect(subject.client).to receive(:measure).with("sidekiq.scheduled", 1)
|
29
|
-
expect(subject.client).to receive(:increment).with("sidekiq.processed")
|
30
|
-
expect(subject.client).to receive(:increment).with("sidekiq.failed")
|
27
|
+
expect(subject.client).to receive(:measure).with("sidekiq.retries", 1).and_call_original
|
28
|
+
expect(subject.client).to receive(:measure).with("sidekiq.scheduled", 1).and_call_original
|
29
|
+
expect(subject.client).to receive(:increment).with("sidekiq.processed").and_call_original
|
30
|
+
expect(subject.client).to receive(:increment).with("sidekiq.failed").and_call_original
|
31
31
|
|
32
32
|
expect do
|
33
33
|
subject.call(nil, nil, nil) do
|
@@ -1,17 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Nightwing::Sidekiq::WorkerStats do
|
4
|
-
|
5
|
-
|
6
|
-
subject { Nightwing::Sidekiq::WorkerStats.new(client: Nightwing::NilClient.new) }
|
4
|
+
subject { Nightwing::Sidekiq::WorkerStats.new(client: Nightwing::DebugClient.new) }
|
7
5
|
|
8
6
|
describe "#call" do
|
9
7
|
context "when everything just works" do
|
10
8
|
it "increments process count" do
|
11
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.processed")
|
12
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.finished")
|
9
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.processed").and_call_original
|
10
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.finished").and_call_original
|
13
11
|
|
14
|
-
subject.call(MyWorker.new,
|
12
|
+
subject.call(MyWorker.new, {}, "default") do
|
15
13
|
# beep
|
16
14
|
end
|
17
15
|
end
|
@@ -19,15 +17,27 @@ describe Nightwing::Sidekiq::WorkerStats do
|
|
19
17
|
|
20
18
|
context "when something fails" do
|
21
19
|
it "increments process and failure count" do
|
22
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.processed")
|
23
|
-
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.failed")
|
20
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.processed").and_call_original
|
21
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.failed").and_call_original
|
24
22
|
|
25
23
|
expect do
|
26
|
-
subject.call(MyWorker.new,
|
24
|
+
subject.call(MyWorker.new, {}, "default") do
|
27
25
|
fail "beep"
|
28
26
|
end
|
29
27
|
end.to raise_error RuntimeError
|
30
28
|
end
|
31
29
|
end
|
30
|
+
|
31
|
+
context "when being retried" do
|
32
|
+
it "increments process and retried count" do
|
33
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.processed").and_call_original
|
34
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.retried").and_call_original
|
35
|
+
expect(subject.client).to receive(:increment).with("sidekiq.default.my_worker.finished").and_call_original
|
36
|
+
|
37
|
+
subject.call(MyWorker.new, { "retry" => 0, "retry_count" => 2 }, "default") do
|
38
|
+
# beep
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nightwing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Ledet
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oink
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rubocop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,18 +119,23 @@ files:
|
|
105
119
|
- CHANGELOG.md
|
106
120
|
- Gemfile
|
107
121
|
- Gemfile.lock
|
122
|
+
- LICENSE.txt
|
108
123
|
- README.md
|
109
124
|
- circle.yml
|
110
125
|
- lib/nightwing.rb
|
126
|
+
- lib/nightwing/client_logger.rb
|
127
|
+
- lib/nightwing/debug_client.rb
|
128
|
+
- lib/nightwing/logger.rb
|
111
129
|
- lib/nightwing/metric.rb
|
112
|
-
- lib/nightwing/nil_client.rb
|
113
130
|
- lib/nightwing/sidekiq/base.rb
|
131
|
+
- lib/nightwing/sidekiq/profiler.rb
|
114
132
|
- lib/nightwing/sidekiq/queue_stats.rb
|
115
133
|
- lib/nightwing/sidekiq/stats.rb
|
116
134
|
- lib/nightwing/sidekiq/worker_stats.rb
|
117
135
|
- lib/nightwing/version.rb
|
118
136
|
- nightwing.gemspec
|
119
137
|
- spec/nightwing/metric_spec.rb
|
138
|
+
- spec/nightwing/sidekiq/profiler_spec.rb
|
120
139
|
- spec/nightwing/sidekiq/queue_stats_spec.rb
|
121
140
|
- spec/nightwing/sidekiq/stats_spec.rb
|
122
141
|
- spec/nightwing/sidekiq/worker_stats_spec.rb
|