nsa 0.1.4 → 0.2.0

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
  SHA1:
3
- metadata.gz: 8b92d60fc72c575b7059744fc7ad297887969b99
4
- data.tar.gz: a5a1297fbde37d29c42777e37d4a8c0591158d4f
3
+ metadata.gz: c1a996fa5af6727cff0da62c3bea2c03121e0e39
4
+ data.tar.gz: b60c21f202615307e3c5c2d0bda20db393fcd79d
5
5
  SHA512:
6
- metadata.gz: 2376bdba06ee689371a168b5886a50d816a4a9b33fb9cb79135f9c434f009d00cb30decb234008a3b9f7df47e4cb5e0febeddf86a7c3ce721729326964116de7
7
- data.tar.gz: 3e6bb3e57fa4f39e89ec689e17f4ae759a0dd72227c12fcce4ff0f38992a5e31f6d6072864ed7901ec39bf4b2ee9b9e4233d2604ab9cb3a137d7b0ab83f6ebd4
6
+ metadata.gz: 22112240d62da1536e1dc24e3f9c904d0c65ab6d8152376a2a124f9f21a6243b7961ed935577f92f3b02c2da460b4001ed51c9ac09aa180420b9dc56ac839e6f
7
+ data.tar.gz: 51a0f98d21e227da7ee8a65df55e272b828e906066d99959c7a78bccf66d540ac59ffd8ca7069f9e850f9d1b3fedbeb742c7e3230c2fbc7dd3a6f7dac7c8e55d
data/lib/nsa.rb CHANGED
@@ -1,11 +1,11 @@
1
- require "nsa/version"
2
- require "nsa/statsd_informant"
3
-
4
1
  module NSA
5
2
 
6
3
  def self.inform_statsd(backend)
7
- yield ::NSA::StatsdInformant
8
- ::NSA::StatsdInformant.listen(backend)
4
+ yield ::NSA::Statsd::Informant
5
+ ::NSA::Statsd::Informant.listen(backend)
9
6
  end
10
7
 
11
8
  end
9
+
10
+ require "nsa/version"
11
+ require "nsa/statsd"
@@ -0,0 +1,4 @@
1
+ require "nsa/statsd/subscriber"
2
+ require "nsa/statsd/publisher"
3
+ require "nsa/statsd/async_publisher"
4
+ require "nsa/statsd/informant"
@@ -0,0 +1,40 @@
1
+ require "concurrent"
2
+
3
+ module NSA
4
+ module Statsd
5
+ module AsyncPublisher
6
+ include ::NSA::Statsd::Publisher
7
+
8
+ def async_statsd_count(key, sample_rate = nil, &block)
9
+ ::Concurrent::Promise.execute(&block).then do |value|
10
+ statsd_count(key, value, sample_rate)
11
+ end
12
+ end
13
+
14
+ def async_statsd_gauge(key, sample_rate = nil, &block)
15
+ ::Concurrent::Promise.execute(&block).then do |value|
16
+ statsd_gauge(key, value, sample_rate)
17
+ end
18
+ end
19
+
20
+ def async_statsd_set(key, sample_rate = nil, &block)
21
+ ::Concurrent::Promise.execute(&block).then do |value|
22
+ statsd_set(key, value, sample_rate)
23
+ end
24
+ end
25
+
26
+ def async_statsd_time(key, sample_rate = nil, &block)
27
+ ::Concurrent::Future.execute do
28
+ statsd_time(key, sample_rate, &block)
29
+ end
30
+ end
31
+
32
+ def async_statsd_timing(key, sample_rate = nil, &block)
33
+ ::Concurrent::Promise.execute(&block).then do |value|
34
+ statsd_timing(key, value, sample_rate)
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,30 @@
1
+ require "nsa/collectors/action_controller"
2
+ require "nsa/collectors/active_record"
3
+ require "nsa/collectors/active_support_cache"
4
+ require "nsa/collectors/null"
5
+ require "nsa/collectors/sidekiq"
6
+
7
+ module NSA
8
+ module Statsd
9
+ module Informant
10
+ extend ::NSA::Statsd::Subscriber
11
+
12
+ COLLECTOR_TYPES = ::Hash.new(::NSA::Collectors::Null).merge({
13
+ :action_controller => ::NSA::Collectors::ActionController,
14
+ :active_record => ::NSA::Collectors::ActiveRecord,
15
+ :active_support_cache => ::NSA::Collectors::ActiveSupportCache,
16
+ :sidekiq => ::NSA::Collectors::Sidekiq
17
+ }).freeze
18
+
19
+ def self.collect(collector, key_prefix)
20
+ collector = COLLECTOR_TYPES[collector.to_sym] unless collector.respond_to?(:collect)
21
+ collector.collect(key_prefix)
22
+ end
23
+
24
+ def self.listen(backend)
25
+ statsd_subscribe(backend)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module NSA
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "activesupport", "~> 4.2.0"
22
+ spec.add_dependency "concurrent-ruby", "~> 1.0.0"
22
23
  spec.add_dependency "sidekiq", ">= 3.5.0"
23
24
  spec.add_dependency "statsd-ruby", "~> 1.2.0"
24
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: concurrent-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: sidekiq
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -143,9 +157,11 @@ files:
143
157
  - lib/nsa/collectors/active_support_cache.rb
144
158
  - lib/nsa/collectors/null.rb
145
159
  - lib/nsa/collectors/sidekiq.rb
160
+ - lib/nsa/statsd.rb
161
+ - lib/nsa/statsd/async_publisher.rb
162
+ - lib/nsa/statsd/informant.rb
146
163
  - lib/nsa/statsd/publisher.rb
147
164
  - lib/nsa/statsd/subscriber.rb
148
- - lib/nsa/statsd_informant.rb
149
165
  - lib/nsa/version.rb
150
166
  - nsa.gemspec
151
167
  - tags
@@ -1,31 +0,0 @@
1
- require "nsa/statsd/subscriber"
2
-
3
- require "nsa/collectors/action_controller"
4
- require "nsa/collectors/active_record"
5
- require "nsa/collectors/active_support_cache"
6
- require "nsa/collectors/null"
7
- require "nsa/collectors/sidekiq"
8
-
9
- module NSA
10
- module StatsdInformant
11
- extend ::NSA::Statsd::Subscriber
12
-
13
- COLLECTOR_TYPES = ::Hash.new(::NSA::Collectors::Null).merge({
14
- :action_controller => ::NSA::Collectors::ActionController,
15
- :active_record => ::NSA::Collectors::ActiveRecord,
16
- :active_support_cache => ::NSA::Collectors::ActiveSupportCache,
17
- :sidekiq => ::NSA::Collectors::Sidekiq
18
- }).freeze
19
-
20
- def self.collect(collector, key_prefix)
21
- collector = COLLECTOR_TYPES[collector.to_sym] unless collector.respond_to?(:collect)
22
- collector.collect(key_prefix)
23
- end
24
-
25
- def self.listen(backend)
26
- statsd_subscribe(backend)
27
- end
28
-
29
- end
30
- end
31
-