harness-action_subscriber 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '04483ecd6328ff52f81134722162f4fd666ec7009caca930140cee966b22f667'
4
- data.tar.gz: 2464d449ec0d22076c8d0ffa245890a23d1c34c894194b23d42d4af8a6a72d01
3
+ metadata.gz: 29d9a5850e5d8449c06fdfcd62ed49b1bfc09a6c035001a92ddff725c95dc90c
4
+ data.tar.gz: 8bd9a77bb53af785515f43e953af8b9b92c2932ef51a3e581b0bce81b8d0c1e3
5
5
  SHA512:
6
- metadata.gz: eda2427b07a8dc80b40325f8b799c6bbe8b19ee95f6d161023666b286ffdfc484a4d1aabe3d0b7ee22db608dd8f43374c1ea104dab84da8f6b71e985071b277f
7
- data.tar.gz: 4569346b1aeb5396027003936479c6cdff06a2907f41846d570b833ef8d87af9b78d32e529b63d88dc6b1464552e75392b6004503895ecd232048bb740ea0ea3
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", "~> 1.10"
22
- spec.add_development_dependency "rake", "~> 10.0"
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
- ::ActiveSupport::Notifications.subscribe "message_acked.action_subscriber" do |*args|
7
- event = ::ActiveSupport::Notifications::Event.new(*args)
8
- event_name = event.payload[:queue].gsub(".", "-")
9
- ::Harness.increment "action_subscriber.messages_acked.#{event_name}"
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 "message_nacked.action_subscriber" do |*args|
14
- event = ::ActiveSupport::Notifications::Event.new(*args)
15
- event_name = event.payload[:queue].gsub(".", "-")
16
- ::Harness.increment "action_subscriber.messages_nacked.#{event_name}"
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
- ::ActiveSupport::Notifications.subscribe "message_rejected.action_subscriber" do |*args|
21
- event = ::ActiveSupport::Notifications::Event.new(*args)
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 "popped_event.action_subscriber" do |*args|
28
- event = ::ActiveSupport::Notifications::Event.new(*args)
29
- event_name = event.payload[:queue].gsub '.', '-'
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 "received_event.action_subscriber" do |*args|
35
- event = ::ActiveSupport::Notifications::Event.new(*args)
36
- event_name = event.payload[:queue].gsub '.', '-'
37
- ::Harness.increment "action_subscriber.received_event.#{event_name}"
38
- ::Harness.gauge "action_subscriber.received_event_bytes.#{event_name}", event.payload[:payload_size]
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
- event = ::ActiveSupport::Notifications::Event.new(*args)
43
- event_name = event.payload[:queue].gsub '.', '-'
44
- ::Harness.timing "action_subscriber.process_event.#{event_name}", event.duration
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
@@ -1,5 +1,5 @@
1
1
  module Harness
2
2
  module ActionSubscriber
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  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.3
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: 2018-12-03 00:00:00.000000000 Z
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: '1.10'
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: '1.10'
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: '10.0'
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: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement