nsa 0.2.1 → 0.2.8

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
- SHA1:
3
- metadata.gz: 86ff263225b7d77e1d87aa520fb425173097effd
4
- data.tar.gz: 723e3953685a9dc67a6c09dbda7e137e5f52a2cc
2
+ SHA256:
3
+ metadata.gz: abd4fef5644f8f3c61e7aa019dcdc65a9b7b5438aef6627d6217547c8aba5ba6
4
+ data.tar.gz: b5c9663cdb0e4bcb08dc187bee2be634c44634da57b3e4b5492844c668480cc5
5
5
  SHA512:
6
- metadata.gz: 41a998fa86f209cc2803eee4f233e7c94ff39e465cf920f37c09cb76245091fa04d15b6023f592e64a9a4abc7c30de322c06dbc603753473a30f1d41ba4f7330
7
- data.tar.gz: 99da7edeabcc395718a7470c24003ed7dd79fef900f138b6ae88b9938b0aa49b8e30ba06be83e9fe46db8a3f5c4b2147eff6fc8d6d2fd9c5cedf341e776f4812
6
+ metadata.gz: 6c862df27c47bf19b7ca6441eb227cb4d66e81109bf07735730f55dbafa2fee389a69784331894496fce61f8df4fb6404e138496e862d65055fdd652b24a201a
7
+ data.tar.gz: 5d589a6580a300497f2bd98e1bc7733363e1a6cad6420834360d5b578f82617a4330bedc410a83dfae5067a40b4a1c6bff2c23ca9a0f322016a9fc37117aee37
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /tags
11
+ *.gem
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- before_install: gem install bundler -v 1.10.6
3
+ - 2.6.5
4
+ before_install: gem install bundler -v 2.1.4
@@ -23,18 +23,20 @@ module NSA
23
23
  end
24
24
 
25
25
  def statsd_time(key, sample_rate = nil, &block)
26
- __statsd_publish(:time, key, nil, sample_rate, &block)
26
+ start = Time.now
27
+ result = block.call unless block.nil?
28
+ statsd_timing(key, ((Time.now - start) * 1000).round, sample_rate)
29
+ result
27
30
  end
28
31
 
29
32
  def statsd_timing(key, value = 1, sample_rate = nil)
30
33
  __statsd_publish(:timing, key, value, sample_rate)
31
34
  end
32
35
 
33
- def __statsd_publish(stat_type, key, value = nil, sample_rate = nil, &block)
36
+ def __statsd_publish(stat_type, key, value = nil, sample_rate = nil)
34
37
  payload = { :key => key }
35
38
  payload.merge!({ :value => value }) if value
36
39
  payload.merge!({ :sample_rate => sample_rate }) if sample_rate
37
- payload.merge!({ :block => block }) if block_given?
38
40
 
39
41
  ::ActiveSupport::Notifications.instrument("#{stat_type}.statsd", payload)
40
42
  end
@@ -21,14 +21,13 @@ module NSA
21
21
 
22
22
  key_name = payload[:key]
23
23
  sample_rate = payload.fetch(:sample_rate, 1)
24
- block = payload[:block]
25
24
 
26
25
  case action.to_sym
27
26
  when :count, :timing, :set, :gauge then
28
27
  value = payload.fetch(:value) { 1 }
29
- backend.__send__(action, key_name, value, sample_rate, &block)
30
- when :increment, :decrement, :time then
31
- backend.__send__(action, key_name, sample_rate, &block)
28
+ backend.__send__(action, key_name, value, sample_rate)
29
+ when :increment, :decrement then
30
+ backend.__send__(action, key_name, sample_rate)
32
31
  end
33
32
  end
34
33
 
data/lib/nsa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NSA
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.8"
3
3
  end
data/nsa.gemspec CHANGED
@@ -9,23 +9,24 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["BJ Neilsen"]
10
10
  spec.email = ["bj.neilsen@gmail.com"]
11
11
 
12
- spec.summary = %q{Listen to your Rails ActiveSupport::Notifications and deliver to a Statsd backend.}
13
- spec.description = spec.summary
14
- spec.homepage = "https://www.github.com/localshred/nsa"
12
+ spec.summary = %q{Publish Rails application metrics to statsd}
13
+ spec.description = %q{Listen to your Rails ActiveSupport::Notifications and deliver to a Statsd compatible backend}
14
+ spec.homepage = "https://github.com/localshred/nsa"
15
+ spec.licenses = ["MIT"]
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
18
  spec.bindir = "exe"
18
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
20
  spec.require_paths = ["lib"]
20
21
 
21
- spec.add_dependency "activesupport", "~> 4.2.0"
22
- spec.add_dependency "concurrent-ruby", "~> 1.0.0"
23
- spec.add_dependency "sidekiq", ">= 3.5.0"
24
- spec.add_dependency "statsd-ruby", "~> 1.2.0"
22
+ spec.add_dependency "activesupport", "< 7", ">= 4.2"
23
+ spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2"
24
+ spec.add_dependency "sidekiq", ">= 3.5"
25
+ spec.add_dependency "statsd-ruby", "~> 1.4", ">= 1.4.0"
25
26
 
26
- spec.add_development_dependency "bundler", "~> 1.10"
27
+ spec.add_development_dependency "bundler", "~> 2.1"
27
28
  spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "minitest"
29
- spec.add_development_dependency "mocha"
30
- spec.add_development_dependency "byebug"
29
+ spec.add_development_dependency "minitest", "~> 5.0"
30
+ spec.add_development_dependency "mocha", "~> 1.11"
31
+ spec.add_development_dependency "byebug", "~> 10"
31
32
  end
metadata CHANGED
@@ -1,85 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-20 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '7'
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
- version: 4.2.0
22
+ version: '4.2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - "<"
25
28
  - !ruby/object:Gem::Version
26
- version: 4.2.0
29
+ version: '7'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '4.2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: concurrent-ruby
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 1.0.0
39
+ version: '1.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.0.2
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
- version: 1.0.0
49
+ version: '1.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.0.2
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: sidekiq
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - ">="
46
58
  - !ruby/object:Gem::Version
47
- version: 3.5.0
59
+ version: '3.5'
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - ">="
53
65
  - !ruby/object:Gem::Version
54
- version: 3.5.0
66
+ version: '3.5'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: statsd-ruby
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
71
  - - "~>"
60
72
  - !ruby/object:Gem::Version
61
- version: 1.2.0
73
+ version: '1.4'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.4.0
62
77
  type: :runtime
63
78
  prerelease: false
64
79
  version_requirements: !ruby/object:Gem::Requirement
65
80
  requirements:
66
81
  - - "~>"
67
82
  - !ruby/object:Gem::Version
68
- version: 1.2.0
83
+ version: '1.4'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 1.4.0
69
87
  - !ruby/object:Gem::Dependency
70
88
  name: bundler
71
89
  requirement: !ruby/object:Gem::Requirement
72
90
  requirements:
73
91
  - - "~>"
74
92
  - !ruby/object:Gem::Version
75
- version: '1.10'
93
+ version: '2.1'
76
94
  type: :development
77
95
  prerelease: false
78
96
  version_requirements: !ruby/object:Gem::Requirement
79
97
  requirements:
80
98
  - - "~>"
81
99
  - !ruby/object:Gem::Version
82
- version: '1.10'
100
+ version: '2.1'
83
101
  - !ruby/object:Gem::Dependency
84
102
  name: rake
85
103
  requirement: !ruby/object:Gem::Requirement
@@ -98,46 +116,46 @@ dependencies:
98
116
  name: minitest
99
117
  requirement: !ruby/object:Gem::Requirement
100
118
  requirements:
101
- - - ">="
119
+ - - "~>"
102
120
  - !ruby/object:Gem::Version
103
- version: '0'
121
+ version: '5.0'
104
122
  type: :development
105
123
  prerelease: false
106
124
  version_requirements: !ruby/object:Gem::Requirement
107
125
  requirements:
108
- - - ">="
126
+ - - "~>"
109
127
  - !ruby/object:Gem::Version
110
- version: '0'
128
+ version: '5.0'
111
129
  - !ruby/object:Gem::Dependency
112
130
  name: mocha
113
131
  requirement: !ruby/object:Gem::Requirement
114
132
  requirements:
115
- - - ">="
133
+ - - "~>"
116
134
  - !ruby/object:Gem::Version
117
- version: '0'
135
+ version: '1.11'
118
136
  type: :development
119
137
  prerelease: false
120
138
  version_requirements: !ruby/object:Gem::Requirement
121
139
  requirements:
122
- - - ">="
140
+ - - "~>"
123
141
  - !ruby/object:Gem::Version
124
- version: '0'
142
+ version: '1.11'
125
143
  - !ruby/object:Gem::Dependency
126
144
  name: byebug
127
145
  requirement: !ruby/object:Gem::Requirement
128
146
  requirements:
129
- - - ">="
147
+ - - "~>"
130
148
  - !ruby/object:Gem::Version
131
- version: '0'
149
+ version: '10'
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
135
153
  requirements:
136
- - - ">="
154
+ - - "~>"
137
155
  - !ruby/object:Gem::Version
138
- version: '0'
156
+ version: '10'
139
157
  description: Listen to your Rails ActiveSupport::Notifications and deliver to a Statsd
140
- backend.
158
+ compatible backend
141
159
  email:
142
160
  - bj.neilsen@gmail.com
143
161
  executables: []
@@ -164,11 +182,11 @@ files:
164
182
  - lib/nsa/statsd/subscriber.rb
165
183
  - lib/nsa/version.rb
166
184
  - nsa.gemspec
167
- - tags
168
- homepage: https://www.github.com/localshred/nsa
169
- licenses: []
185
+ homepage: https://github.com/localshred/nsa
186
+ licenses:
187
+ - MIT
170
188
  metadata: {}
171
- post_install_message:
189
+ post_install_message:
172
190
  rdoc_options: []
173
191
  require_paths:
174
192
  - lib
@@ -183,10 +201,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
201
  - !ruby/object:Gem::Version
184
202
  version: '0'
185
203
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.4.5
188
- signing_key:
204
+ rubygems_version: 3.2.15
205
+ signing_key:
189
206
  specification_version: 4
190
- summary: Listen to your Rails ActiveSupport::Notifications and deliver to a Statsd
191
- backend.
207
+ summary: Publish Rails application metrics to statsd
192
208
  test_files: []
data/tags DELETED
@@ -1,63 +0,0 @@
1
- !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2
- !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3
- !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4
- !_TAG_PROGRAM_NAME Exuberant Ctags //
5
- !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
- !_TAG_PROGRAM_VERSION 5.8 //
7
- ActionController lib/nsa/collectors/action_controller.rb /^ module ActionController$/;" m class:NSA.Collectors
8
- ActiveRecord lib/nsa/collectors/active_record.rb /^ module ActiveRecord$/;" m class:NSA.Collectors
9
- ActiveSupportCache lib/nsa/collectors/active_support_cache.rb /^ module ActiveSupportCache$/;" m class:NSA.Collectors
10
- CACHE_TYPES lib/nsa/collectors/active_support_cache.rb /^ CACHE_TYPES = {$/;" c
11
- COLLECTOR_TYPES lib/nsa/statsd_informant.rb /^ COLLECTOR_TYPES = ::Hash.new(::NSA::Collectors::Null).merge({$/;" c
12
- Collectors lib/nsa/collectors/action_controller.rb /^ module Collectors$/;" m class:NSA
13
- Collectors lib/nsa/collectors/active_record.rb /^ module Collectors$/;" m class:NSA
14
- Collectors lib/nsa/collectors/active_support_cache.rb /^ module Collectors$/;" m class:NSA
15
- Collectors lib/nsa/collectors/null.rb /^ module Collectors$/;" m class:NSA
16
- Collectors lib/nsa/collectors/sidekiq.rb /^ module Collectors$/;" m class:NSA
17
- EMPTY_MATCH_RESULT lib/nsa/collectors/active_record.rb /^ EMPTY_MATCH_RESULT = []$/;" c
18
- EXPECTED_RESPONDABLE_METHODS lib/nsa/statsd/subscriber.rb /^ EXPECTED_RESPONDABLE_METHODS = %i( count decrement gauge increment set time timing ).freeze$/;" c
19
- LoadError lib/nsa/collectors/sidekiq.rb /^ rescue ::LoadError => exception$/;" c
20
- MATCHERS lib/nsa/collectors/active_record.rb /^ MATCHERS = [$/;" c
21
- NSA lib/nsa.rb /^module NSA$/;" m
22
- NSA lib/nsa/collectors/action_controller.rb /^module NSA$/;" m
23
- NSA lib/nsa/collectors/active_record.rb /^module NSA$/;" m
24
- NSA lib/nsa/collectors/active_support_cache.rb /^module NSA$/;" m
25
- NSA lib/nsa/collectors/null.rb /^module NSA$/;" m
26
- NSA lib/nsa/collectors/sidekiq.rb /^module NSA$/;" m
27
- NSA lib/nsa/statsd/publisher.rb /^module NSA$/;" m
28
- NSA lib/nsa/statsd/subscriber.rb /^module NSA$/;" m
29
- NSA lib/nsa/statsd_informant.rb /^module NSA$/;" m
30
- NSA lib/nsa/version.rb /^module NSA$/;" m
31
- Null lib/nsa/collectors/null.rb /^ module Null$/;" m class:NSA.Collectors
32
- Publisher lib/nsa/statsd/publisher.rb /^ module Publisher$/;" m class:NSA.Statsd
33
- Sidekiq lib/nsa/collectors/sidekiq.rb /^ class Sidekiq$/;" c class:NSA.Collectors
34
- Statsd lib/nsa/statsd/publisher.rb /^ module Statsd$/;" m class:NSA
35
- Statsd lib/nsa/statsd/subscriber.rb /^ module Statsd$/;" m class:NSA
36
- StatsdInformant lib/nsa/statsd_informant.rb /^ module StatsdInformant$/;" m class:NSA
37
- Subscriber lib/nsa/statsd/subscriber.rb /^ module Subscriber$/;" m class:NSA.Statsd
38
- VERSION lib/nsa/version.rb /^ VERSION = "0.1.4"$/;" c
39
- __send_event_to_statsd lib/nsa/statsd/subscriber.rb /^ def __send_event_to_statsd(backend, name, start, finish, id, payload)$/;" f class:NSA.Statsd.Subscriber
40
- __statsd_publish lib/nsa/statsd/publisher.rb /^ def __statsd_publish(stat_type, key, value = nil, sample_rate = nil, &block)$/;" f class:NSA.Statsd.Publisher
41
- backend_valid? lib/nsa/statsd/subscriber.rb /^ def backend_valid?(backend)$/;" f class:NSA.Statsd.Subscriber
42
- call lib/nsa/collectors/sidekiq.rb /^ def call(worker, message, queue_name)$/;" f class:NSA.Collectors.Sidekiq
43
- collect lib/nsa/collectors/action_controller.rb /^ def self.collect(key_prefix)$/;" F class:NSA.Collectors.ActionController
44
- collect lib/nsa/collectors/active_record.rb /^ def self.collect(key_prefix)$/;" F class:NSA.Collectors.ActiveRecord
45
- collect lib/nsa/collectors/active_support_cache.rb /^ def self.collect(key_prefix)$/;" F class:NSA.Collectors.ActiveSupportCache
46
- collect lib/nsa/collectors/null.rb /^ def self.collect(*_)$/;" F class:NSA.Collectors.Null
47
- collect lib/nsa/collectors/sidekiq.rb /^ def self.collect(key_prefix)$/;" F class:NSA.Collectors.Sidekiq
48
- collect lib/nsa/statsd_informant.rb /^ def self.collect(collector, key_prefix)$/;" F class:NSA.StatsdInformant
49
- inform_statsd lib/nsa.rb /^ def self.inform_statsd(backend)$/;" F class:NSA
50
- initialize lib/nsa/collectors/sidekiq.rb /^ def initialize(key_prefix)$/;" f class:NSA.Collectors.Sidekiq
51
- listen lib/nsa/statsd_informant.rb /^ def self.listen(backend)$/;" F class:NSA.StatsdInformant
52
- make_key lib/nsa/collectors/sidekiq.rb /^ def make_key(*args)$/;" f class:NSA.Collectors.Sidekiq
53
- match_query lib/nsa/collectors/active_record.rb /^ def self.match_query(sql)$/;" F class:NSA.Collectors
54
- publish_overall_stats lib/nsa/collectors/sidekiq.rb /^ def publish_overall_stats$/;" f class:NSA.Collectors.Sidekiq
55
- publish_queue_size_and_latency lib/nsa/collectors/sidekiq.rb /^ def publish_queue_size_and_latency(queue_name)$/;" f class:NSA.Collectors.Sidekiq
56
- statsd_count lib/nsa/statsd/publisher.rb /^ def statsd_count(key, value = 1, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher
57
- statsd_decrement lib/nsa/statsd/publisher.rb /^ def statsd_decrement(key, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher
58
- statsd_gauge lib/nsa/statsd/publisher.rb /^ def statsd_gauge(key, value = 1, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher
59
- statsd_increment lib/nsa/statsd/publisher.rb /^ def statsd_increment(key, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher
60
- statsd_set lib/nsa/statsd/publisher.rb /^ def statsd_set(key, value = 1, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher
61
- statsd_subscribe lib/nsa/statsd/subscriber.rb /^ def statsd_subscribe(backend)$/;" f class:NSA.Statsd.Subscriber
62
- statsd_time lib/nsa/statsd/publisher.rb /^ def statsd_time(key, sample_rate = nil, &block)$/;" f class:NSA.Statsd.Publisher
63
- statsd_timing lib/nsa/statsd/publisher.rb /^ def statsd_timing(key, value = 1, sample_rate = nil)$/;" f class:NSA.Statsd.Publisher