nsa 0.2.8 → 0.3.0
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 +4 -4
- data/README.md +27 -16
- data/lib/nsa/collectors/sidekiq.rb +1 -1
- data/lib/nsa/version.rb +1 -1
- data/nsa.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37e17700593bdc086519eeb89241d961cb1f6f922e10989be1a6954167563be3
|
4
|
+
data.tar.gz: d0079fd977a6d6788941af123769d739f06fb9530c496e05c4c10a8660dcace5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3882d5dd4e2bf8e0c967a76faf16a8c0999d34621bcf76995adf9db748e55ede984a668a774dd9cf628606660e4f135b2952762ec89650e5d572d555ba98b42
|
7
|
+
data.tar.gz: 5e9fe626719980e222f37993a944680802027ccdf7906ae47d957f100fd52eaab595a5ffcc3f971b93a7d9c83d62cd1d5f4b9f2005073626b62c2e74056aecbe
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# NSA (National Statsd Agency)
|
2
2
|
|
3
|
-
Listen to Rails `ActiveSupport::Notifications` and deliver to a
|
4
|
-
This gem also supports
|
3
|
+
Listen to Rails `ActiveSupport::Notifications` and deliver to a
|
4
|
+
[Statsd](https://github.com/reinh/statsd) backend. This gem also supports
|
5
|
+
writing your own custom collectors.
|
5
6
|
|
6
7
|
[](https://badge.fury.io/rb/nsa)
|
7
8
|
[](https://travis-ci.org/localshred/nsa)
|
@@ -24,8 +25,8 @@ Or install it yourself as:
|
|
24
25
|
|
25
26
|
## Usage
|
26
27
|
|
27
|
-
NSA comes packaged with collectors for ActionController, ActiveRecord,
|
28
|
-
and Sidekiq.
|
28
|
+
NSA comes packaged with collectors for ActionController, ActiveRecord,
|
29
|
+
ActiveSupport Caching, and Sidekiq.
|
29
30
|
|
30
31
|
To use this gem, simply get a reference to a statsd backend, then indicate which
|
31
32
|
collectors you'd like to run. Each `collect` method specifies a Collector to use
|
@@ -106,11 +107,15 @@ Metrics recorded:
|
|
106
107
|
|
107
108
|
## Writing your own collector
|
108
109
|
|
109
|
-
Writing your own collector is very simple. To take advantage of the keyspace
|
110
|
+
Writing your own collector is very simple. To take advantage of the keyspace
|
111
|
+
handling you must:
|
110
112
|
|
111
|
-
1. Create an object/module which responds to `collect`, taking the `key_prefix`
|
112
|
-
|
113
|
-
|
113
|
+
1. Create an object/module which responds to `collect`, taking the `key_prefix`
|
114
|
+
as its only argument.
|
115
|
+
2. Include or extend your class/module with `NSA::Statsd::Publisher` or
|
116
|
+
`NSA::Statsd::Publisher`.
|
117
|
+
3. Call any of the `statsd_*` prefixed methods provided by the included
|
118
|
+
Publisher:
|
114
119
|
|
115
120
|
__`Publisher` methods:__
|
116
121
|
|
@@ -130,12 +135,13 @@ __`AsyncPublisher` methods:__
|
|
130
135
|
+ `async_statsd_time(key, sample_rate = nil, &block)`
|
131
136
|
+ `async_statsd_timing(key, sample_rate = nil, &block)`
|
132
137
|
|
133
|
-
___Note:___ When using the `AsyncPublisher`, the value is derived from the
|
134
|
-
when the value is not near at hand and has a relatively
|
135
|
-
and you don't want your current thread to
|
138
|
+
___Note:___ When using the `AsyncPublisher`, the value is derived from the
|
139
|
+
block. This is useful when the value is not near at hand and has a relatively
|
140
|
+
high cost to compute (e.g. db query) and you don't want your current thread to
|
141
|
+
wait.
|
136
142
|
|
137
|
-
For example, first define your collector. Our (very naive) example will write
|
138
|
-
|
143
|
+
For example, first define your collector. Our (very naive) example will write a
|
144
|
+
gauge metric every 10 seconds of the User count in the db.
|
139
145
|
|
140
146
|
```ruby
|
141
147
|
# Publishing User.count gauge using a collector
|
@@ -189,11 +195,16 @@ the thread responsible for creating the record (and processing more callbacks).
|
|
189
195
|
|
190
196
|
## Development
|
191
197
|
|
192
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
198
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
199
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
200
|
+
prompt that will allow you to experiment.
|
193
201
|
|
194
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
202
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
203
|
+
release a new version, update the version number in `version.rb`, and then run
|
204
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
205
|
+
git commits and tags, and push the `.gem` file to
|
206
|
+
[rubygems.org](https://rubygems.org).
|
195
207
|
|
196
208
|
## Contributing
|
197
209
|
|
198
210
|
Bug reports and pull requests are welcome on GitHub at https://github.com/localshred/nsa.
|
199
|
-
|
data/lib/nsa/version.rb
CHANGED
data/nsa.gemspec
CHANGED
@@ -19,13 +19,13 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "activesupport", "< 7", ">= 4.2"
|
22
|
+
spec.add_dependency "activesupport", "< 7.2", ">= 4.2"
|
23
23
|
spec.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2"
|
24
24
|
spec.add_dependency "sidekiq", ">= 3.5"
|
25
25
|
spec.add_dependency "statsd-ruby", "~> 1.4", ">= 1.4.0"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.1"
|
28
|
-
spec.add_development_dependency "rake", "~>
|
28
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
29
|
spec.add_development_dependency "minitest", "~> 5.0"
|
30
30
|
spec.add_development_dependency "mocha", "~> 1.11"
|
31
31
|
spec.add_development_dependency "byebug", "~> 10"
|
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.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2024-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '7'
|
19
|
+
version: '7.2'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - "<"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '7'
|
29
|
+
version: '7.2'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.2'
|
@@ -104,14 +104,14 @@ dependencies:
|
|
104
104
|
requirements:
|
105
105
|
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
107
|
+
version: '13.0'
|
108
108
|
type: :development
|
109
109
|
prerelease: false
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
112
|
- - "~>"
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: '
|
114
|
+
version: '13.0'
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: minitest
|
117
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
|
-
rubygems_version: 3.
|
204
|
+
rubygems_version: 3.3.26
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Publish Rails application metrics to statsd
|