ndr_stats 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +262 -0
- data/README.md +102 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/code_safety.yml +242 -0
- data/lib/ndr_stats.rb +43 -0
- data/lib/ndr_stats/config.rb +16 -0
- data/lib/ndr_stats/ping.rb +87 -0
- data/lib/ndr_stats/railtie.rb +22 -0
- data/lib/ndr_stats/stats.rb +30 -0
- data/lib/ndr_stats/version.rb +3 -0
- data/ndr_stats.gemspec +31 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 07aa65a15f2fdb87c420ce417026f05f302454ae208e61e46b45918a3d5d1c85
|
4
|
+
data.tar.gz: 87c64140b5c6a5cd5aafad38bfa855da85c92ece1593020c85f7e7c19b41a8ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dec94d62f9e9486f628a12a541c613a46ecf39e407f76b6e28a5ac99c83adb299ac5f9b4f6baf2b7f423eb527792e1f08c6429735725efac5e1e3bc985c95f7d
|
7
|
+
data.tar.gz: bbefe813dd0e53227391560b4851e13587590038c1ad06797d389fde45e3e4b2fb9f28bba6f974d4c696e99ad8b3452a6c8d8d9f9e538e9397b22b759811e7c5
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: 'https://raw.githubusercontent.com/PublicHealthEngland/ndr_dev_support/master/.rubocop.yml'
|
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.5
|
6
|
+
- 2.6
|
7
|
+
before_install:
|
8
|
+
- gem install bundler -v 2.0.1
|
9
|
+
- rm Gemfile.lock
|
10
|
+
script: bundle exec rake test
|
11
|
+
notifications:
|
12
|
+
slack:
|
13
|
+
rooms:
|
14
|
+
secure: gAmGsKm7wt0Qn/1eP9Kk/md/Dy9/eXjjPpxUhkOB9C17aJUbHWWtJ1HKDpkdOyp1lM3IjJuDHpE927XoOFgcQ0jFBZVrHfrbrW4Abt8kRMZTEqeY1OZWiuDo/ArrEon6PUXXEFeXpMzdnU9HN2jPQ2Nd2FhpW7lBkWTvOg1U2L6yrb5xNQ6XwT8wNzlVu2BqZ/b/s114SpdQ/efCOnT/vXb4dPUGaYjgopmNcuR1rtITGLMV51thLPy/1bNYl2+OtJUOXOWLEb4dSxuwYWwvzRoeIzh+Hu62Ml5Ih0l/KVfdwQDbRKjgGCp7fmOqZfxheMl7h4eq/0CVQSWA7z21qymhDwLcJ16fY39ijEKWnAwI5BuaMFM8SWl9xsO04i/XP7+GrGFhhopGuqLSQhFc/V/FIFgKz3C6VxY5IIOZ4NHazJP1uMrpQNBPvKbt4trPtlVKPt7KsfgJE/pJISpLhLes/KNalHUpKaNtxEg/JmLCTzjj6KCRLV0yT6Hi1isQtDn13GUtgriI2MLk1mxMBp9bICTIIJO49jcFT+j6XcAWPdawPBTvZlb4w4G0CyYDs/EDPSvbME2L0tDExPHMaUYWEL11vMki1vgsv8KrfOalQtzFgmyyqADIFH0ALkJAD6VY0YooZT2ymKj1uMCCx7UTtOCbpTrhWJhljunHTIs=
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at josh.pencheon@googlemail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,262 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ndr_stats (0.2.1)
|
5
|
+
dogstatsd-ruby (~> 4.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.0.1)
|
11
|
+
actionpack (= 6.0.1)
|
12
|
+
nio4r (~> 2.0)
|
13
|
+
websocket-driver (>= 0.6.1)
|
14
|
+
actionmailbox (6.0.1)
|
15
|
+
actionpack (= 6.0.1)
|
16
|
+
activejob (= 6.0.1)
|
17
|
+
activerecord (= 6.0.1)
|
18
|
+
activestorage (= 6.0.1)
|
19
|
+
activesupport (= 6.0.1)
|
20
|
+
mail (>= 2.7.1)
|
21
|
+
actionmailer (6.0.1)
|
22
|
+
actionpack (= 6.0.1)
|
23
|
+
actionview (= 6.0.1)
|
24
|
+
activejob (= 6.0.1)
|
25
|
+
mail (~> 2.5, >= 2.5.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
actionpack (6.0.1)
|
28
|
+
actionview (= 6.0.1)
|
29
|
+
activesupport (= 6.0.1)
|
30
|
+
rack (~> 2.0)
|
31
|
+
rack-test (>= 0.6.3)
|
32
|
+
rails-dom-testing (~> 2.0)
|
33
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
34
|
+
actiontext (6.0.1)
|
35
|
+
actionpack (= 6.0.1)
|
36
|
+
activerecord (= 6.0.1)
|
37
|
+
activestorage (= 6.0.1)
|
38
|
+
activesupport (= 6.0.1)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
actionview (6.0.1)
|
41
|
+
activesupport (= 6.0.1)
|
42
|
+
builder (~> 3.1)
|
43
|
+
erubi (~> 1.4)
|
44
|
+
rails-dom-testing (~> 2.0)
|
45
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
46
|
+
activejob (6.0.1)
|
47
|
+
activesupport (= 6.0.1)
|
48
|
+
globalid (>= 0.3.6)
|
49
|
+
activemodel (6.0.1)
|
50
|
+
activesupport (= 6.0.1)
|
51
|
+
activerecord (6.0.1)
|
52
|
+
activemodel (= 6.0.1)
|
53
|
+
activesupport (= 6.0.1)
|
54
|
+
activestorage (6.0.1)
|
55
|
+
actionpack (= 6.0.1)
|
56
|
+
activejob (= 6.0.1)
|
57
|
+
activerecord (= 6.0.1)
|
58
|
+
marcel (~> 0.3.1)
|
59
|
+
activesupport (6.0.1)
|
60
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
61
|
+
i18n (>= 0.7, < 2)
|
62
|
+
minitest (~> 5.1)
|
63
|
+
tzinfo (~> 1.1)
|
64
|
+
zeitwerk (~> 2.2)
|
65
|
+
addressable (2.7.0)
|
66
|
+
public_suffix (>= 2.0.2, < 5.0)
|
67
|
+
ast (2.4.0)
|
68
|
+
brakeman (4.7.1)
|
69
|
+
builder (3.2.3)
|
70
|
+
bundler-audit (0.6.1)
|
71
|
+
bundler (>= 1.2.0, < 3)
|
72
|
+
thor (~> 0.18)
|
73
|
+
capistrano (2.15.9)
|
74
|
+
highline
|
75
|
+
net-scp (>= 1.0.0)
|
76
|
+
net-sftp (>= 2.0.0)
|
77
|
+
net-ssh (>= 2.0.14)
|
78
|
+
net-ssh-gateway (>= 1.1.0)
|
79
|
+
capybara (3.29.0)
|
80
|
+
addressable
|
81
|
+
mini_mime (>= 0.1.3)
|
82
|
+
nokogiri (~> 1.8)
|
83
|
+
rack (>= 1.6.0)
|
84
|
+
rack-test (>= 0.6.3)
|
85
|
+
regexp_parser (~> 1.5)
|
86
|
+
xpath (~> 3.2)
|
87
|
+
capybara-screenshot (1.0.24)
|
88
|
+
capybara (>= 1.0, < 4)
|
89
|
+
launchy
|
90
|
+
charlock_holmes (0.7.7)
|
91
|
+
childprocess (3.0.0)
|
92
|
+
cliver (0.3.2)
|
93
|
+
coderay (1.1.2)
|
94
|
+
concurrent-ruby (1.1.5)
|
95
|
+
crass (1.0.5)
|
96
|
+
docile (1.3.2)
|
97
|
+
dogstatsd-ruby (4.5.0)
|
98
|
+
erubi (1.9.0)
|
99
|
+
escape_utils (1.2.1)
|
100
|
+
github-linguist (7.6.1)
|
101
|
+
charlock_holmes (~> 0.7.6)
|
102
|
+
escape_utils (~> 1.2.0)
|
103
|
+
mini_mime (~> 1.0)
|
104
|
+
rugged (>= 0.25.1)
|
105
|
+
globalid (0.4.2)
|
106
|
+
activesupport (>= 4.2.0)
|
107
|
+
highline (2.0.3)
|
108
|
+
i18n (1.7.0)
|
109
|
+
concurrent-ruby (~> 1.0)
|
110
|
+
jaro_winkler (1.5.4)
|
111
|
+
json (2.2.0)
|
112
|
+
launchy (2.4.3)
|
113
|
+
addressable (~> 2.3)
|
114
|
+
loofah (2.3.1)
|
115
|
+
crass (~> 1.0.2)
|
116
|
+
nokogiri (>= 1.5.9)
|
117
|
+
mail (2.7.1)
|
118
|
+
mini_mime (>= 0.1.1)
|
119
|
+
marcel (0.3.3)
|
120
|
+
mimemagic (~> 0.3.2)
|
121
|
+
metaclass (0.0.4)
|
122
|
+
method_source (0.9.2)
|
123
|
+
mimemagic (0.3.3)
|
124
|
+
mini_mime (1.0.2)
|
125
|
+
mini_portile2 (2.4.0)
|
126
|
+
minitest (5.13.0)
|
127
|
+
mocha (1.9.0)
|
128
|
+
metaclass (~> 0.0.1)
|
129
|
+
ndr_dev_support (5.4.5)
|
130
|
+
activesupport (< 6.1)
|
131
|
+
brakeman (>= 4.2.0)
|
132
|
+
bundler-audit
|
133
|
+
capistrano (~> 2.15)
|
134
|
+
capybara (>= 3.20)
|
135
|
+
capybara-screenshot
|
136
|
+
github-linguist
|
137
|
+
highline (>= 1.6.0)
|
138
|
+
parser
|
139
|
+
poltergeist (>= 1.8.0)
|
140
|
+
prometheus-client (>= 0.9.0)
|
141
|
+
pry
|
142
|
+
rainbow
|
143
|
+
rubocop (= 0.71.0)
|
144
|
+
rugged
|
145
|
+
selenium-webdriver
|
146
|
+
show_me_the_cookies
|
147
|
+
simplecov
|
148
|
+
unicode-display_width (>= 1.3.3)
|
149
|
+
webdrivers (>= 3.9)
|
150
|
+
with_clean_rbenv
|
151
|
+
net-scp (2.0.0)
|
152
|
+
net-ssh (>= 2.6.5, < 6.0.0)
|
153
|
+
net-sftp (2.1.2)
|
154
|
+
net-ssh (>= 2.6.5)
|
155
|
+
net-ssh (5.2.0)
|
156
|
+
net-ssh-gateway (2.0.0)
|
157
|
+
net-ssh (>= 4.0.0)
|
158
|
+
nio4r (2.5.2)
|
159
|
+
nokogiri (1.10.5)
|
160
|
+
mini_portile2 (~> 2.4.0)
|
161
|
+
parallel (1.19.1)
|
162
|
+
parser (2.6.5.0)
|
163
|
+
ast (~> 2.4.0)
|
164
|
+
poltergeist (1.18.1)
|
165
|
+
capybara (>= 2.1, < 4)
|
166
|
+
cliver (~> 0.3.1)
|
167
|
+
websocket-driver (>= 0.2.0)
|
168
|
+
prometheus-client (1.0.0)
|
169
|
+
pry (0.12.2)
|
170
|
+
coderay (~> 1.1.0)
|
171
|
+
method_source (~> 0.9.0)
|
172
|
+
public_suffix (4.0.1)
|
173
|
+
rack (2.0.7)
|
174
|
+
rack-test (1.1.0)
|
175
|
+
rack (>= 1.0, < 3)
|
176
|
+
rails (6.0.1)
|
177
|
+
actioncable (= 6.0.1)
|
178
|
+
actionmailbox (= 6.0.1)
|
179
|
+
actionmailer (= 6.0.1)
|
180
|
+
actionpack (= 6.0.1)
|
181
|
+
actiontext (= 6.0.1)
|
182
|
+
actionview (= 6.0.1)
|
183
|
+
activejob (= 6.0.1)
|
184
|
+
activemodel (= 6.0.1)
|
185
|
+
activerecord (= 6.0.1)
|
186
|
+
activestorage (= 6.0.1)
|
187
|
+
activesupport (= 6.0.1)
|
188
|
+
bundler (>= 1.3.0)
|
189
|
+
railties (= 6.0.1)
|
190
|
+
sprockets-rails (>= 2.0.0)
|
191
|
+
rails-dom-testing (2.0.3)
|
192
|
+
activesupport (>= 4.2.0)
|
193
|
+
nokogiri (>= 1.6)
|
194
|
+
rails-html-sanitizer (1.3.0)
|
195
|
+
loofah (~> 2.3)
|
196
|
+
railties (6.0.1)
|
197
|
+
actionpack (= 6.0.1)
|
198
|
+
activesupport (= 6.0.1)
|
199
|
+
method_source
|
200
|
+
rake (>= 0.8.7)
|
201
|
+
thor (>= 0.20.3, < 2.0)
|
202
|
+
rainbow (3.0.0)
|
203
|
+
rake (10.5.0)
|
204
|
+
regexp_parser (1.6.0)
|
205
|
+
rubocop (0.71.0)
|
206
|
+
jaro_winkler (~> 1.5.1)
|
207
|
+
parallel (~> 1.10)
|
208
|
+
parser (>= 2.6)
|
209
|
+
rainbow (>= 2.2.2, < 4.0)
|
210
|
+
ruby-progressbar (~> 1.7)
|
211
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
212
|
+
ruby-progressbar (1.10.1)
|
213
|
+
rubyzip (2.0.0)
|
214
|
+
rugged (0.28.3.1)
|
215
|
+
selenium-webdriver (3.142.6)
|
216
|
+
childprocess (>= 0.5, < 4.0)
|
217
|
+
rubyzip (>= 1.2.2)
|
218
|
+
show_me_the_cookies (5.0.0)
|
219
|
+
capybara (>= 2, < 4)
|
220
|
+
simplecov (0.17.1)
|
221
|
+
docile (~> 1.1)
|
222
|
+
json (>= 1.8, < 3)
|
223
|
+
simplecov-html (~> 0.10.0)
|
224
|
+
simplecov-html (0.10.2)
|
225
|
+
sprockets (4.0.0)
|
226
|
+
concurrent-ruby (~> 1.0)
|
227
|
+
rack (> 1, < 3)
|
228
|
+
sprockets-rails (3.2.1)
|
229
|
+
actionpack (>= 4.0)
|
230
|
+
activesupport (>= 4.0)
|
231
|
+
sprockets (>= 3.0.0)
|
232
|
+
thor (0.20.3)
|
233
|
+
thread_safe (0.3.6)
|
234
|
+
tzinfo (1.2.5)
|
235
|
+
thread_safe (~> 0.1)
|
236
|
+
unicode-display_width (1.6.0)
|
237
|
+
webdrivers (4.1.3)
|
238
|
+
nokogiri (~> 1.6)
|
239
|
+
rubyzip (>= 1.3.0)
|
240
|
+
selenium-webdriver (>= 3.0, < 4.0)
|
241
|
+
websocket-driver (0.7.1)
|
242
|
+
websocket-extensions (>= 0.1.0)
|
243
|
+
websocket-extensions (0.1.4)
|
244
|
+
with_clean_rbenv (0.1.0)
|
245
|
+
xpath (3.2.0)
|
246
|
+
nokogiri (~> 1.8)
|
247
|
+
zeitwerk (2.2.1)
|
248
|
+
|
249
|
+
PLATFORMS
|
250
|
+
ruby
|
251
|
+
|
252
|
+
DEPENDENCIES
|
253
|
+
bundler (~> 2.0)
|
254
|
+
minitest (~> 5.0)
|
255
|
+
mocha
|
256
|
+
ndr_dev_support
|
257
|
+
ndr_stats!
|
258
|
+
rails
|
259
|
+
rake (~> 10.0)
|
260
|
+
|
261
|
+
BUNDLED WITH
|
262
|
+
2.0.1
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# NdrStats [![Build Status](https://travis-ci.org/PublicHealthEngland/ndr_stats.svg?branch=master)](https://travis-ci.org/PublicHealthEngland/ndr_stats)
|
2
|
+
|
3
|
+
Provides pain-free setup of stats collecting to Ruby/Rails projects.
|
4
|
+
|
5
|
+
## Assumed Architecture
|
6
|
+
|
7
|
+
This library currently sends UDP packets to the configured receiver using the statsd format (with tagging addition).
|
8
|
+
|
9
|
+
The conventional way we set this up is as follows:
|
10
|
+
|
11
|
+
```
|
12
|
+
+-------------+ UDP +----------------------------+
|
13
|
+
| Ruby client | ----> | Prometheus Statsd Exporter |
|
14
|
+
+-------------+ +----------------------------+
|
15
|
+
|
|
16
|
+
| scraped by
|
17
|
+
V
|
18
|
+
+---------+ +-----------------------+
|
19
|
+
| Grafana | <---- | Central Prometheus DB |
|
20
|
+
+---------+ +-----------------------+
|
21
|
+
```
|
22
|
+
|
23
|
+
## Setup
|
24
|
+
|
25
|
+
### Ruby
|
26
|
+
|
27
|
+
First, set up the library to point at a Statsd receiver:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
NdrStats.configure(host: 'localhost', port: 9125)
|
31
|
+
```
|
32
|
+
|
33
|
+
### Rails
|
34
|
+
|
35
|
+
When used in a Rails application, you can store configuration in `config/stats.yml`.
|
36
|
+
|
37
|
+
```yaml
|
38
|
+
---
|
39
|
+
host: localhost
|
40
|
+
port: 9125
|
41
|
+
```
|
42
|
+
|
43
|
+
It's additionally possible to specify `system` and `stack`, which will be automatically added as tags on all stats.
|
44
|
+
If the host application's enclosing module responds to the `flavour` or `stack` methods, these will be used if not otherwise specified.
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
Basic usage is as follows:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
# increment counts of things:
|
52
|
+
NdrStats.count(:issues)
|
53
|
+
NdrStats.count(:issues, 3)
|
54
|
+
|
55
|
+
# time things:
|
56
|
+
NdrStats.time(:paint_drying) { paint.dry! }
|
57
|
+
NdrStats.timing(:web_request, 100) # milliseconds
|
58
|
+
|
59
|
+
# set counts of things:
|
60
|
+
NdrStats.gauge(:population, 8_000_000_000)
|
61
|
+
```
|
62
|
+
|
63
|
+
All methods additionally accept tags, sent using the DataDog format extension:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
NdrStats.count(:issues, +1, type: :closed)
|
67
|
+
NdrStats.count(:issues, -1, type: :open)
|
68
|
+
```
|
69
|
+
|
70
|
+
### Pings
|
71
|
+
|
72
|
+
You can register background pings (for process status checks) using `NdrStats.ping`,
|
73
|
+
by supplying tags. These will also use any default tags you have configured.
|
74
|
+
|
75
|
+
Metrics:
|
76
|
+
* `ndr_stats_initial_ping` is incremented once, initially
|
77
|
+
* `ndr_stats_ping` is then incremented periodically, according to the frequency
|
78
|
+
* `ndr_stats_final_ping` is incremented once on exit, if it's possible to do so.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# basic tagged ping:
|
82
|
+
NdrStats.ping(type: 'webapp')
|
83
|
+
|
84
|
+
# supply additional tags:
|
85
|
+
NdrStats.ping(type: 'daemon', name: 'batch importer')
|
86
|
+
|
87
|
+
# set a custom frequency (defaults to every minute):
|
88
|
+
NdrStats.ping(type: 'sloth', every: 3.hours)
|
89
|
+
```
|
90
|
+
|
91
|
+
See `NdrStats::Ping` for more details.
|
92
|
+
|
93
|
+
## Development
|
94
|
+
|
95
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
96
|
+
|
97
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git co
|
98
|
+
|
99
|
+
|
100
|
+
## Code of Conduct
|
101
|
+
|
102
|
+
Everyone interacting in the NdrStats project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the `CODE_OF_CONDUCT.md`.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ndr_stats"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/code_safety.yml
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
---
|
2
|
+
file safety:
|
3
|
+
".gitignore":
|
4
|
+
comments:
|
5
|
+
reviewed_by: josh.pencheon
|
6
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
7
|
+
".rubocop.yml":
|
8
|
+
comments:
|
9
|
+
reviewed_by: josh.pencheon
|
10
|
+
safe_revision: fc8003c597890c4b6f7c4aea3a34bd06b3c1ec6e
|
11
|
+
".travis.yml":
|
12
|
+
comments:
|
13
|
+
reviewed_by: josh.pencheon
|
14
|
+
safe_revision: 39743de484c34d33547ab9e47645542d87138189
|
15
|
+
CHANGELOG.md:
|
16
|
+
comments:
|
17
|
+
reviewed_by: josh.pencheon
|
18
|
+
safe_revision: 0be7f37d7b65df4f465133015399f37e316169c2
|
19
|
+
CODE_OF_CONDUCT.md:
|
20
|
+
comments:
|
21
|
+
reviewed_by: josh.pencheon
|
22
|
+
safe_revision: 43fe7d83291cd9f68a530f615c5b325ea1096366
|
23
|
+
Gemfile:
|
24
|
+
comments:
|
25
|
+
reviewed_by: josh.pencheon
|
26
|
+
safe_revision: e3307b8b5ace6d968887421768e45c1c9024eb04
|
27
|
+
Gemfile.lock:
|
28
|
+
comments:
|
29
|
+
reviewed_by: josh.pencheon
|
30
|
+
safe_revision: 0be7f37d7b65df4f465133015399f37e316169c2
|
31
|
+
README.md:
|
32
|
+
comments:
|
33
|
+
reviewed_by: josh.pencheon
|
34
|
+
safe_revision: e1342a484f0eb0c43c44e43578648b747785e75c
|
35
|
+
Rakefile:
|
36
|
+
comments:
|
37
|
+
reviewed_by: josh.pencheon
|
38
|
+
safe_revision: e3307b8b5ace6d968887421768e45c1c9024eb04
|
39
|
+
bin/console:
|
40
|
+
comments:
|
41
|
+
reviewed_by: josh.pencheon
|
42
|
+
safe_revision: 43fe7d83291cd9f68a530f615c5b325ea1096366
|
43
|
+
bin/setup:
|
44
|
+
comments:
|
45
|
+
reviewed_by: josh.pencheon
|
46
|
+
safe_revision: 43fe7d83291cd9f68a530f615c5b325ea1096366
|
47
|
+
lib/ndr_stats.rb:
|
48
|
+
comments:
|
49
|
+
reviewed_by: josh.pencheon
|
50
|
+
safe_revision: 5f8db00671db37f8a461d81238a7222d4cb4b04d
|
51
|
+
lib/ndr_stats/config.rb:
|
52
|
+
comments:
|
53
|
+
reviewed_by: josh.pencheon
|
54
|
+
safe_revision: f63534ea9c2a0616bc598db4b49805495f3d8581
|
55
|
+
lib/ndr_stats/ping.rb:
|
56
|
+
comments:
|
57
|
+
reviewed_by: josh.pencheon
|
58
|
+
safe_revision: c98ff89227a1855b731c127922b86abe9d489cb8
|
59
|
+
lib/ndr_stats/railtie.rb:
|
60
|
+
comments:
|
61
|
+
reviewed_by: josh.pencheon
|
62
|
+
safe_revision: 3d1d490572a331ad5acadb3189b708e5dc9e1f0e
|
63
|
+
lib/ndr_stats/stats.rb:
|
64
|
+
comments:
|
65
|
+
reviewed_by: josh.pencheon
|
66
|
+
safe_revision: f63534ea9c2a0616bc598db4b49805495f3d8581
|
67
|
+
lib/ndr_stats/version.rb:
|
68
|
+
comments:
|
69
|
+
reviewed_by: josh.pencheon
|
70
|
+
safe_revision: 0be7f37d7b65df4f465133015399f37e316169c2
|
71
|
+
ndr_stats.gemspec:
|
72
|
+
comments:
|
73
|
+
reviewed_by: josh.pencheon
|
74
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
75
|
+
test/dummy/.ruby-version:
|
76
|
+
comments:
|
77
|
+
reviewed_by: josh.pencheon
|
78
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
79
|
+
test/dummy/README.md:
|
80
|
+
comments:
|
81
|
+
reviewed_by: josh.pencheon
|
82
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
83
|
+
test/dummy/Rakefile:
|
84
|
+
comments:
|
85
|
+
reviewed_by: josh.pencheon
|
86
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
87
|
+
test/dummy/app/assets/config/manifest.js:
|
88
|
+
comments:
|
89
|
+
reviewed_by: josh.pencheon
|
90
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
91
|
+
test/dummy/app/assets/stylesheets/application.css:
|
92
|
+
comments:
|
93
|
+
reviewed_by: josh.pencheon
|
94
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
95
|
+
test/dummy/app/controllers/application_controller.rb:
|
96
|
+
comments:
|
97
|
+
reviewed_by: josh.pencheon
|
98
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
99
|
+
test/dummy/app/helpers/application_helper.rb:
|
100
|
+
comments:
|
101
|
+
reviewed_by: josh.pencheon
|
102
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
103
|
+
test/dummy/app/jobs/application_job.rb:
|
104
|
+
comments:
|
105
|
+
reviewed_by: josh.pencheon
|
106
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
107
|
+
test/dummy/app/views/layouts/application.html.erb:
|
108
|
+
comments:
|
109
|
+
reviewed_by: josh.pencheon
|
110
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
111
|
+
test/dummy/bin/rails:
|
112
|
+
comments:
|
113
|
+
reviewed_by: josh.pencheon
|
114
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
115
|
+
test/dummy/bin/rake:
|
116
|
+
comments:
|
117
|
+
reviewed_by: josh.pencheon
|
118
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
119
|
+
test/dummy/bin/setup:
|
120
|
+
comments:
|
121
|
+
reviewed_by: josh.pencheon
|
122
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
123
|
+
test/dummy/config.ru:
|
124
|
+
comments:
|
125
|
+
reviewed_by: josh.pencheon
|
126
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
127
|
+
test/dummy/config/application.rb:
|
128
|
+
comments:
|
129
|
+
reviewed_by: josh.pencheon
|
130
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
131
|
+
test/dummy/config/boot.rb:
|
132
|
+
comments:
|
133
|
+
reviewed_by: josh.pencheon
|
134
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
135
|
+
test/dummy/config/credentials.yml.enc:
|
136
|
+
comments: just contains a secret_key_base for testing
|
137
|
+
reviewed_by: josh.pencheon
|
138
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
139
|
+
test/dummy/config/environment.rb:
|
140
|
+
comments:
|
141
|
+
reviewed_by: josh.pencheon
|
142
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
143
|
+
test/dummy/config/environments/development.rb:
|
144
|
+
comments:
|
145
|
+
reviewed_by: josh.pencheon
|
146
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
147
|
+
test/dummy/config/environments/production.rb:
|
148
|
+
comments:
|
149
|
+
reviewed_by: josh.pencheon
|
150
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
151
|
+
test/dummy/config/environments/test.rb:
|
152
|
+
comments:
|
153
|
+
reviewed_by: josh.pencheon
|
154
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
155
|
+
test/dummy/config/initializers/application_controller_renderer.rb:
|
156
|
+
comments:
|
157
|
+
reviewed_by: josh.pencheon
|
158
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
159
|
+
test/dummy/config/initializers/backtrace_silencers.rb:
|
160
|
+
comments:
|
161
|
+
reviewed_by: josh.pencheon
|
162
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
163
|
+
test/dummy/config/initializers/content_security_policy.rb:
|
164
|
+
comments:
|
165
|
+
reviewed_by: josh.pencheon
|
166
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
167
|
+
test/dummy/config/initializers/cookies_serializer.rb:
|
168
|
+
comments:
|
169
|
+
reviewed_by: josh.pencheon
|
170
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
171
|
+
test/dummy/config/initializers/filter_parameter_logging.rb:
|
172
|
+
comments:
|
173
|
+
reviewed_by: josh.pencheon
|
174
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
175
|
+
test/dummy/config/initializers/inflections.rb:
|
176
|
+
comments:
|
177
|
+
reviewed_by: josh.pencheon
|
178
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
179
|
+
test/dummy/config/initializers/mime_types.rb:
|
180
|
+
comments:
|
181
|
+
reviewed_by: josh.pencheon
|
182
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
183
|
+
test/dummy/config/initializers/wrap_parameters.rb:
|
184
|
+
comments:
|
185
|
+
reviewed_by: josh.pencheon
|
186
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
187
|
+
test/dummy/config/locales/en.yml:
|
188
|
+
comments:
|
189
|
+
reviewed_by: josh.pencheon
|
190
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
191
|
+
test/dummy/config/master.key:
|
192
|
+
comments: Purely to allow tests to work. Protects no real secrets.
|
193
|
+
reviewed_by: josh.pencheon
|
194
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
195
|
+
test/dummy/config/routes.rb:
|
196
|
+
comments:
|
197
|
+
reviewed_by: josh.pencheon
|
198
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
199
|
+
test/dummy/public/404.html:
|
200
|
+
comments:
|
201
|
+
reviewed_by: josh.pencheon
|
202
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
203
|
+
test/dummy/public/422.html:
|
204
|
+
comments:
|
205
|
+
reviewed_by: josh.pencheon
|
206
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
207
|
+
test/dummy/public/500.html:
|
208
|
+
comments:
|
209
|
+
reviewed_by: josh.pencheon
|
210
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
211
|
+
test/dummy/public/apple-touch-icon-precomposed.png:
|
212
|
+
comments:
|
213
|
+
reviewed_by: josh.pencheon
|
214
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
215
|
+
test/dummy/public/apple-touch-icon.png:
|
216
|
+
comments:
|
217
|
+
reviewed_by: josh.pencheon
|
218
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
219
|
+
test/dummy/public/favicon.ico:
|
220
|
+
comments:
|
221
|
+
reviewed_by: josh.pencheon
|
222
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
223
|
+
test/dummy/public/robots.txt:
|
224
|
+
comments:
|
225
|
+
reviewed_by: josh.pencheon
|
226
|
+
safe_revision: 1da1afebc89e581f409615c084d47adfb0b8265f
|
227
|
+
test/ndr_stats/ping_test.rb:
|
228
|
+
comments:
|
229
|
+
reviewed_by: josh.pencheon
|
230
|
+
safe_revision: c98ff89227a1855b731c127922b86abe9d489cb8
|
231
|
+
test/ndr_stats_test.rb:
|
232
|
+
comments:
|
233
|
+
reviewed_by: josh.pencheon
|
234
|
+
safe_revision: f63534ea9c2a0616bc598db4b49805495f3d8581
|
235
|
+
test/railtie_test.rb:
|
236
|
+
comments:
|
237
|
+
reviewed_by: josh.pencheon
|
238
|
+
safe_revision: e52ce3caa8d48115f63a71c1ae1bf5757ecfa129
|
239
|
+
test/test_helper.rb:
|
240
|
+
comments:
|
241
|
+
reviewed_by: josh.pencheon
|
242
|
+
safe_revision: f63534ea9c2a0616bc598db4b49805495f3d8581
|
data/lib/ndr_stats.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'ndr_stats/version'
|
2
|
+
|
3
|
+
require 'ndr_stats/config'
|
4
|
+
require 'ndr_stats/ping'
|
5
|
+
require 'ndr_stats/railtie' if defined?(Rails)
|
6
|
+
require 'ndr_stats/stats'
|
7
|
+
|
8
|
+
# Code to allow instrumentation to be fed back to prometheus.
|
9
|
+
#
|
10
|
+
# # Icrement a counter by one:
|
11
|
+
# NdrStats.count('sheep', colour: 'black')
|
12
|
+
# # Or by many:
|
13
|
+
# NdrStats.count('rabbits', 10)
|
14
|
+
#
|
15
|
+
# # Set a gauge:
|
16
|
+
# NdrStats.gauge('active_daemons', 10)
|
17
|
+
#
|
18
|
+
# # Time some code:
|
19
|
+
# NdrStats.time('validation', class: 'Tumour') { @tumour.valid? }
|
20
|
+
#
|
21
|
+
module NdrStats
|
22
|
+
extend Config
|
23
|
+
extend Stats
|
24
|
+
|
25
|
+
class << self
|
26
|
+
attr_accessor :adaptor
|
27
|
+
|
28
|
+
# Register some tags to update the :ping counter periodically.
|
29
|
+
#
|
30
|
+
# # basic tagged ping:
|
31
|
+
# NdrStats.ping(type: 'webapp')
|
32
|
+
|
33
|
+
# # supply additional tags:
|
34
|
+
# NdrStats.ping(type: 'daemon', name: 'batch importer')
|
35
|
+
|
36
|
+
# # set a custom frequency (defaults to every minute):
|
37
|
+
# NdrStats.ping(type: 'sloth', every: 3.hours)
|
38
|
+
#
|
39
|
+
def ping(**args)
|
40
|
+
Ping.register(**args)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# A fork of the original ruby client, that supports tagging:
|
2
|
+
require 'datadog/statsd'
|
3
|
+
|
4
|
+
module NdrStats
|
5
|
+
# Contains configuration/setup logic
|
6
|
+
module Config
|
7
|
+
def configure(host:, port:, system: nil, stack: nil)
|
8
|
+
tags = { system: system, stack: stack }.reject { |_key, value| value.nil? }
|
9
|
+
NdrStats.adaptor = Datadog::Statsd.new(host, port, tags: tags)
|
10
|
+
end
|
11
|
+
|
12
|
+
def configured?
|
13
|
+
!NdrStats.adaptor.nil?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module NdrStats
|
2
|
+
# Ping instances make regular increments to a :ping counter,
|
3
|
+
# as a means of checking that a progress is up.
|
4
|
+
#
|
5
|
+
# They can be started and stopped, as well as registered and removed
|
6
|
+
# centrally. Generally, use via `NdrStats.ping` is recommended.
|
7
|
+
class Ping
|
8
|
+
# Maintain a list of started instances, to avoid accidentally
|
9
|
+
# starting duplicates.
|
10
|
+
class << self
|
11
|
+
def list
|
12
|
+
@list ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def register(**args)
|
16
|
+
instance = new(**args)
|
17
|
+
|
18
|
+
if list.detect { |other| other.tags == instance.tags }
|
19
|
+
raise ArgumentError, 'another tagged instance already exists!'
|
20
|
+
else
|
21
|
+
list << instance
|
22
|
+
end
|
23
|
+
|
24
|
+
instance.tap(&:start)
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove_all
|
28
|
+
list.each(&:stop)
|
29
|
+
list.clear
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# trigger final pings, if possible:
|
34
|
+
at_exit { Ping.remove_all }
|
35
|
+
|
36
|
+
attr_reader :interval, :tags
|
37
|
+
|
38
|
+
def initialize(every: 60, type:, **tags)
|
39
|
+
@interval = every
|
40
|
+
@tags = tags.merge!(type: type)
|
41
|
+
|
42
|
+
@thread = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def start
|
46
|
+
raise 'already started!' if running?
|
47
|
+
|
48
|
+
initial_ping
|
49
|
+
@thread = Thread.new { ping_forever }
|
50
|
+
self
|
51
|
+
end
|
52
|
+
|
53
|
+
def stop
|
54
|
+
return unless @thread
|
55
|
+
|
56
|
+
@thread.kill
|
57
|
+
@thread.join
|
58
|
+
|
59
|
+
final_ping
|
60
|
+
end
|
61
|
+
|
62
|
+
def running?
|
63
|
+
@thread&.alive?
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def ping_forever
|
69
|
+
loop do
|
70
|
+
running_ping
|
71
|
+
sleep interval
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def initial_ping
|
76
|
+
NdrStats.count(:ndr_stats_initial_ping, **tags)
|
77
|
+
end
|
78
|
+
|
79
|
+
def running_ping
|
80
|
+
NdrStats.count(:ndr_stats_ping, **tags)
|
81
|
+
end
|
82
|
+
|
83
|
+
def final_ping
|
84
|
+
NdrStats.count(:ndr_stats_final_ping, **tags)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module NdrStats
|
2
|
+
# Behaviour that runs when this gem is used in the context of a Rail app.
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
# Auto-configures NdrStats with config in the host app, if found.
|
5
|
+
config.after_initialize do
|
6
|
+
config_file = Rails.root.join('config', 'stats.yml')
|
7
|
+
next unless File.exist?(config_file)
|
8
|
+
|
9
|
+
config = YAML.load_file(config_file).symbolize_keys.
|
10
|
+
slice(:host, :port, :system, :stack).
|
11
|
+
reject { |_, value| value.blank? }
|
12
|
+
|
13
|
+
# Try and derive system/stack from applications that expose it:
|
14
|
+
app_class = Rails.application.class
|
15
|
+
host_module = app_class.try(:module_parent) || app_class.parent
|
16
|
+
config[:system] ||= host_module.try(:flavour) || host_module.name.downcase
|
17
|
+
config[:stack] ||= host_module.try(:stack) || Rails.env
|
18
|
+
|
19
|
+
NdrStats.configure(**config)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module NdrStats
|
2
|
+
# The supported types of measurement. Currently just mirrors what
|
3
|
+
# the statsd format supports, with the addition of tagging through
|
4
|
+
# DataDog's extension to the serialisation format.
|
5
|
+
module Stats
|
6
|
+
def timing(name, value, **tags)
|
7
|
+
return unless configured?
|
8
|
+
|
9
|
+
adaptor.timing(name, value, tags: tags)
|
10
|
+
end
|
11
|
+
|
12
|
+
def time(name, **tags, &block)
|
13
|
+
return yield unless configured?
|
14
|
+
|
15
|
+
adaptor.time(name, tags: tags, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def count(name, by = 1, **tags)
|
19
|
+
return unless configured?
|
20
|
+
|
21
|
+
adaptor.count(name, by, tags: tags)
|
22
|
+
end
|
23
|
+
|
24
|
+
def gauge(name, value, **tags)
|
25
|
+
return unless configured?
|
26
|
+
|
27
|
+
adaptor.gauge(name, value, tags: tags)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/ndr_stats.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'ndr_stats/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'ndr_stats'
|
7
|
+
spec.version = NdrStats::VERSION
|
8
|
+
spec.authors = ['NCRS Development team']
|
9
|
+
spec.email = []
|
10
|
+
spec.summary = 'Easy stats reporting from Ruby'
|
11
|
+
spec.description = 'Makes it straightforward for a project to send data to statsd.'
|
12
|
+
|
13
|
+
# Specify which files should be added to the gem when it is released.
|
14
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
15
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
16
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
end
|
18
|
+
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'dogstatsd-ruby', '~> 4.5'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
27
|
+
spec.add_development_dependency 'mocha'
|
28
|
+
spec.add_development_dependency 'ndr_dev_support'
|
29
|
+
spec.add_development_dependency 'rails'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ndr_stats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- NCRS Development team
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dogstatsd-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ndr_dev_support
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
description: Makes it straightforward for a project to send data to statsd.
|
112
|
+
email: []
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- ".gitignore"
|
118
|
+
- ".rubocop.yml"
|
119
|
+
- ".travis.yml"
|
120
|
+
- CHANGELOG.md
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- code_safety.yml
|
129
|
+
- lib/ndr_stats.rb
|
130
|
+
- lib/ndr_stats/config.rb
|
131
|
+
- lib/ndr_stats/ping.rb
|
132
|
+
- lib/ndr_stats/railtie.rb
|
133
|
+
- lib/ndr_stats/stats.rb
|
134
|
+
- lib/ndr_stats/version.rb
|
135
|
+
- ndr_stats.gemspec
|
136
|
+
homepage:
|
137
|
+
licenses: []
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubygems_version: 3.0.3
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Easy stats reporting from Ruby
|
158
|
+
test_files: []
|