harness-action_subscriber 0.0.3 → 0.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d9a5850e5d8449c06fdfcd62ed49b1bfc09a6c035001a92ddff725c95dc90c
|
4
|
+
data.tar.gz: 8bd9a77bb53af785515f43e953af8b9b92c2932ef51a3e581b0bce81b8d0c1e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c19330c8015172e9877cc44fcf77207e0ae30167b0a2722855ec54015a328769bd183fd67c03956ec49d82082887020bc5dcbdbafb2c865f4eb3944012a3c8
|
7
|
+
data.tar.gz: eaad275b309775d6cd75df3f4e39f7827bd54a7bfc107c1438012a1662629a6a3961c05d68edb77f079d486b88f0f2d0957f5f05574d45a55bbc5a28e22188be
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler"
|
22
|
-
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "activesupport", ">= 3.2"
|
@@ -3,43 +3,62 @@ require "harness/action_subscriber/version"
|
|
3
3
|
require "harness"
|
4
4
|
require "active_support"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
::Harness.timing "action_subscriber.ack_duration.#{event_name}", event.duration
|
11
|
-
end
|
6
|
+
module Harness
|
7
|
+
module ActionSubscriber
|
8
|
+
UNBLOCKED_METRIC = ["action_subscriber", ENV["SERVICE_NAME"], "connection", "unblocked"].reject(&:nil?).join(".").freeze
|
9
|
+
REASON_IS_MISSING = "reason_for_blocking_is_missing"
|
12
10
|
|
13
|
-
::ActiveSupport::Notifications.subscribe "
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
::Harness.timing "action_subscriber.nack_duration.#{event_name}", event.duration
|
18
|
-
end
|
11
|
+
::ActiveSupport::Notifications.subscribe "connection_blocked.action_subscriber" do |_, _, _, _, params|
|
12
|
+
reason = params.fetch(:reason) || REASON_IS_MISSING
|
13
|
+
blocked_metric = ["action_subscriber", ENV["SERVICE_NAME"], "connection", "blocked", reason.gsub(/\W/, "_")].
|
14
|
+
reject(&:nil?).join(".")
|
19
15
|
|
20
|
-
::
|
21
|
-
|
22
|
-
event_name = event.payload[:queue].gsub(".", "-")
|
23
|
-
::Harness.increment "action_subscriber.messages_rejected.#{event_name}"
|
24
|
-
::Harness.timing "action_subscriber.reject_duration.#{event_name}", event.duration
|
25
|
-
end
|
16
|
+
::Harness.increment blocked_metric
|
17
|
+
end
|
26
18
|
|
27
|
-
::ActiveSupport::Notifications.subscribe "
|
28
|
-
|
29
|
-
|
30
|
-
::Harness.increment "action_subscriber.popped_event.#{event_name}"
|
31
|
-
::Harness.gauge "action_subscriber.popped_event_bytes.#{event_name}", event.payload[:payload_size]
|
32
|
-
end
|
19
|
+
::ActiveSupport::Notifications.subscribe "connection_unblocked.action_subscriber" do
|
20
|
+
::Harness.increment UNBLOCKED_METRIC
|
21
|
+
end
|
33
22
|
|
34
|
-
::ActiveSupport::Notifications.subscribe "
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
23
|
+
::ActiveSupport::Notifications.subscribe "message_acked.action_subscriber" do |*args|
|
24
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
25
|
+
event_name = event.payload[:queue].gsub(".", "-")
|
26
|
+
::Harness.increment "action_subscriber.messages_acked.#{event_name}"
|
27
|
+
::Harness.timing "action_subscriber.ack_duration.#{event_name}", event.duration
|
28
|
+
end
|
29
|
+
|
30
|
+
::ActiveSupport::Notifications.subscribe "message_nacked.action_subscriber" do |*args|
|
31
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
32
|
+
event_name = event.payload[:queue].gsub(".", "-")
|
33
|
+
::Harness.increment "action_subscriber.messages_nacked.#{event_name}"
|
34
|
+
::Harness.timing "action_subscriber.nack_duration.#{event_name}", event.duration
|
35
|
+
end
|
36
|
+
|
37
|
+
::ActiveSupport::Notifications.subscribe "message_rejected.action_subscriber" do |*args|
|
38
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
39
|
+
event_name = event.payload[:queue].gsub(".", "-")
|
40
|
+
::Harness.increment "action_subscriber.messages_rejected.#{event_name}"
|
41
|
+
::Harness.timing "action_subscriber.reject_duration.#{event_name}", event.duration
|
42
|
+
end
|
43
|
+
|
44
|
+
::ActiveSupport::Notifications.subscribe "popped_event.action_subscriber" do |*args|
|
45
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
46
|
+
event_name = event.payload[:queue].gsub '.', '-'
|
47
|
+
::Harness.increment "action_subscriber.popped_event.#{event_name}"
|
48
|
+
::Harness.gauge "action_subscriber.popped_event_bytes.#{event_name}", event.payload[:payload_size]
|
49
|
+
end
|
50
|
+
|
51
|
+
::ActiveSupport::Notifications.subscribe "received_event.action_subscriber" do |*args|
|
52
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
53
|
+
event_name = event.payload[:queue].gsub '.', '-'
|
54
|
+
::Harness.increment "action_subscriber.received_event.#{event_name}"
|
55
|
+
::Harness.gauge "action_subscriber.received_event_bytes.#{event_name}", event.payload[:payload_size]
|
56
|
+
end
|
40
57
|
|
41
|
-
::ActiveSupport::Notifications.subscribe "process_event.action_subscriber" do |*args|
|
42
|
-
|
43
|
-
|
44
|
-
|
58
|
+
::ActiveSupport::Notifications.subscribe "process_event.action_subscriber" do |*args|
|
59
|
+
event = ::ActiveSupport::Notifications::Event.new(*args)
|
60
|
+
event_name = event.payload[:queue].gsub '.', '-'
|
61
|
+
::Harness.timing "action_subscriber.process_event.#{event_name}", event.duration
|
62
|
+
end
|
63
|
+
end
|
45
64
|
end
|
@@ -13,6 +13,28 @@ describe ::Harness::ActionSubscriber do
|
|
13
13
|
expect(Harness::ActionSubscriber::VERSION).not_to be nil
|
14
14
|
end
|
15
15
|
|
16
|
+
describe "connection_blocked.action_subscriber" do
|
17
|
+
before { ::ENV["SERVICE_NAME"] = "my_app" }
|
18
|
+
after { ::ENV.delete("SERVICE_NAME") }
|
19
|
+
|
20
|
+
it "increments the connection blocked count" do
|
21
|
+
expect(collector).to receive(:increment).with("action_subscriber.my_app.connection.blocked.low_on_memory")
|
22
|
+
::ActiveSupport::Notifications.instrument("connection_blocked.action_subscriber", :reason => "low on memory")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "uses a default reason when missing" do
|
26
|
+
expect(collector).to receive(:increment).with("action_subscriber.my_app.connection.blocked.reason_for_blocking_is_missing")
|
27
|
+
::ActiveSupport::Notifications.instrument("connection_blocked.action_subscriber", :reason => nil)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "connection_unblocked.action_subscriber" do
|
32
|
+
it "increments the connection unblocked count" do
|
33
|
+
expect(collector).to receive(:increment).with("action_subscriber.connection.unblocked")
|
34
|
+
::ActiveSupport::Notifications.instrument("connection_unblocked.action_subscriber")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
16
38
|
describe "message_acked.action_subscriber" do
|
17
39
|
it "increments the message_acked counter" do
|
18
40
|
expect(collector).to receive(:increment).with("action_subscriber.messages_acked.abacus-amigo-user-created")
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harness-action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mmmries
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|