null_statsd 1.0.0 → 1.0.1

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: bdcda9d6bbce5d1ed55cac57ca33e769c6bfc9b2e18b4a3b852d183f37258d90
4
- data.tar.gz: 9cb8dd40167d522dd1eb21dfce10e7e1318b2b20492465d5e110e6ae9c043769
3
+ metadata.gz: 8a03895a65a1b40080b50230a67e3d78d1b2feebe4440a955fc7c5643d2934f0
4
+ data.tar.gz: ab2409351d7d8e46108689b7732fc6ed0e71e2b67cd7bbe80e9cb3cf88f0ceea
5
5
  SHA512:
6
- metadata.gz: 4501b0cfc958c6c872ed08dcc2ed0ef0e2c0903f9211a067970fc0d6b3f2821dd2e8061958e12275860afb29ffdd99f114ac4bc064cb48914b1f577f8ac4f2e8
7
- data.tar.gz: 5ce718a612489f86b4f2c5502c9eedf2e14f465696a2f09860c0403f05d82faef948465057c0d5c71b8c2785972568696a47d6d50c5d9b1488eab23b9d066989
6
+ metadata.gz: d1207c5fb60d4a4e39ecbffdf84ec0894e4e8fb7c693e08675164ec10a7e467556650dc1bd97791ed5859398c6dd0405d09a3f5d7dea631cab82200dd795fdd8
7
+ data.tar.gz: f201c0a149a66a10eb21b05feb63b069c0f6d27ea4816d7945e0fddf8b941d46b398a43899a2240b7d0d9bdd26f8a49ad1f753c41ca398713015bdc3929e9d8c
data/.gitignore CHANGED
@@ -1,9 +1,5 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ .ruby-version
2
+ .ruby-gemset
3
+ Gemfile.lock
4
+ *.gem
5
+ coverage/
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # NullStatsd
2
2
 
3
- NullStatsd is a [Statsd](https://github.com/statsd/statsd) implementation which utilizes the
4
- [Null Object Pattern](https://en.wikipedia.org/wiki/Null_object_pattern), allowing for a fully
5
- stubbed Statsd object in your development and testing environments.
3
+ NullStatsd is a [Null Object Pattern](https://en.wikipedia.org/wiki/Null_object_pattern)
4
+ implementation of a [Statsd](https://github.com/statsd/statsd) client, allowing for
5
+ conveniently stubbed Statsd objects in your development and testing environments.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,28 +22,36 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Create a thin wrapper around your Statsd implementation:
25
+ Create a wrapper around your Statsd implementation:
26
26
 
27
27
  ```ruby
28
28
  module MyStatsd
29
29
  def self.new
30
- if ENV["STATSD_HOST"] # OR if Rails.development || Rails.staging ...
31
- Statsd.new(statsd_host, statsd_port, *additional_params)
30
+ if ENV["STATSD_HOST"] && ENV["STATSD_PORT"]
31
+ Statsd.new(ENV["STATSD_HOST"], ENV["STATSD_PORT"])
32
32
  else
33
- NullStatsd::Statsd.new(host: statsd_host, port: statsd_port, logger: Rails.logger)
33
+ NullStatsd::Statsd.new(host: "fake.host", port: 1234, logger: Logger.new($stderr))
34
34
  end
35
35
  end
36
36
  end
37
+
38
+ # or perhaps
39
+
40
+ if Rails.env.production? || Rails.env.staging?
41
+ $statsd = Datadog::Statsd.new(ENV["DD_HOST"], ENV["DD_PORT"])
42
+ else
43
+ $statsd = NullStatsd::Statsd.new(host: "fa.ke", port: 42, logger: Rails.logger)
44
+ end
37
45
  ```
38
46
 
39
47
  Create an instance and use it as normal:
40
48
 
41
49
  ```ruby
42
50
  MyStatsd.new.increment(...)
51
+ $statsd.increment(...)
43
52
  ```
44
53
 
45
- Notice that your `statsd` endpoint is _not_ receiving data. Also notice that your _logs_ are
46
- receiving data.
54
+ Notice that your `statsd` endpoint is _not_ receiving data, but your logs are.
47
55
 
48
56
  ```
49
57
  [NullStatsD host:42] Incrementing media.book.consumed with opts {"genre":"science_fiction"}
@@ -51,118 +59,62 @@ receiving data.
51
59
  [NullStatsD host:42] Recording timing info in book.checkout -> 0.512917 sec
52
60
  ```
53
61
 
54
- ### Supported API
62
+ ### Supported Calls
55
63
 
56
64
  ```ruby
57
- instance = NullStatsd::Statsd.new(host: "fake.com", port: 4242, logger: Logger.new($stdout))
58
- ```
65
+ statsd = NullStatsd::Statsd.new(host: "a.co" port: 42, logger: Logger.new($stdout))
66
+ # => [NullStatsD a.co:42] Connecting to fake Statsd, pretending to be on fake.com:4242
59
67
 
60
- > [NullStatsD :-] Connecting to fake Statsd, pretending to be on fake.com:4242
68
+ statsd.increment "media.book.consumed", genre: "horror"
69
+ # => [NullStatsD a.co:42] Incrementing media.book.consumed with opts {"genre":"horror"}
61
70
 
62
- #### increment(stat, opts = {})
71
+ statsd.decrement "media.book.on_hand", genre: "science fiction"
72
+ # => [NullStatsD a.co:42] Decrementing media.book.on_hand with opts {"genre":"science fiction"}
63
73
 
64
- ```ruby
65
- instance.increment "media.book.consumed", genre: "horror"
66
- ```
74
+ statsd.count "responses", 3
75
+ # => [NullStatsD a.co:42] Increasing responses by 3
67
76
 
68
- > [NullStatsD :-] Incrementing media.book.consumed with opts genre:horror
77
+ statsd.gauge "media.book.return_time", 12, measurement: "days"
78
+ # => [NullStatsD a.co:42] Setting gauge media.book.return_time to 12 with opts {"measurement":"days"}
69
79
 
70
- #### decrement(stat, opts = {})
80
+ statsd.histogram "media.book.lent.hour", 42
81
+ # => [NullStatsD a.co:42] Logging histogram media.book.lent.hour -> 42
71
82
 
72
- ```ruby
73
- instance.decrement "media.book.on_hand", genre: "science fiction"
74
- ```
75
-
76
- > [NullStatsD :-] Decrementing media.book.on_hand with opts genre:science fiction
77
-
78
- #### count(stat, opts = {})
79
-
80
- ```ruby
81
- instance.count "responses", 3
82
- ```
83
+ statsd.timing "book checkout", 94, tags: "speedy"
84
+ # => [NullStatsD a.co:42] Timing book checkout at 94 ms with opts {"tags":"speedy"}
83
85
 
84
- > [NullStatsD :-] Increasing responses by 3
86
+ statsd.set "media.book.lent", 10_000_000
87
+ # => [NullStatsD a.co:42] Setting media.book.lent to 10000000
85
88
 
86
- #### guage(stat, opts = {})
89
+ statsd.service_check "door.locked", "ok"
90
+ # => [NullStatsD a.co:42] Service check door.locked: ok
87
91
 
88
- ```ruby
89
- instance.guage "media.book.return_time", 12, measurement: "days"
90
- ```
91
-
92
- > [NullStatsD :-] Setting guage media.book.return_time to 12 with opts measurement:days
93
-
94
- #### histogram(stat, opts = {})
95
-
96
- ```ruby
97
- instance.histogram "media.book.lent.hour", 42
98
- ```
99
-
100
- > [NullStatsD :-] Logging histogram media.book.lent.hour -> 42
101
-
102
- #### timing(stat, ms, opts = {})
103
-
104
- ```ruby
105
- instance.timing "book checkout", 94, tags: "speedy"
106
- ```
92
+ statsd.event "Leak", "The library roof has a leak on the west end. Please take care"
93
+ # => [NullStatsD a.co:42] Event Leak: The library roof has a leak on the west end. Please take care
107
94
 
108
- > [NullStatsD :-] Timing book checkout at 94 ms with opts tags:speedy
109
-
110
- #### set(stat, opts = {})
111
-
112
- ```ruby
113
- instance.set "media.book.lent", 10_000_000
114
- ```
115
-
116
- > [NullStatsD :-] Setting media.book.lent to 10000000
117
-
118
- #### service_check(stat, opts = {})
119
-
120
- ```ruby
121
- instance.service_check "door.locked", "ok"
122
- ```
123
-
124
- > [NullStatsD :-] Service check door.locked: ok
125
-
126
- #### event(stat, opts = {})
127
-
128
- ```ruby
129
- instance.event "Leak", "The library roof has a leak on the west end. Please take care"
130
- ```
131
-
132
- > [NullStatsD :-] Event Leak: The library roof has a leak on the west end. Please take care
133
-
134
- #### time(stat, opts = {})
135
-
136
- ```ruby
137
- instance.time("media.movie.consume") do
95
+ statsd.time("media.movie.consume") do
138
96
  Movie.new().watch
139
97
  end
140
- ```
141
-
142
- > [NullStatsD :-] Recording timing info in media.movie.consumed -> 12323 sec
98
+ # => [NullStatsD a.co:42] Recording timing info in media.movie.consumed -> 12323.23 sec
143
99
 
144
- #### close(stat, opts = {})
100
+ statsd.close
101
+ # => [NullStatsD a.co:42] Close called
145
102
 
146
- ```ruby
147
- instance.close
103
+ statsd.batch do |s|
104
+ s.increment "foo.bar"
105
+ s.increment "baz"
106
+ end
107
+ # This just executes the block, yielding the statsd instance to it.
148
108
  ```
149
109
 
150
- > [NullStatsD :-] Close called
151
-
152
110
  ## Testing
153
111
 
154
112
  `rake spec`
155
113
 
156
114
  ## License
157
115
 
158
- The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
116
+ This gem is available as open source under the terms of the [MIT License](LICENSE.txt).
159
117
 
160
118
  ## Contributing
161
119
 
162
- 1. Fork it
163
- 2. Create your feature branch (`git checkout -b my-new-feature`)
164
- 3. Commit your changes (`git commit -am 'Add some feature'`)
165
- 4. Push to the branch (`git push origin my-new-feature`)
166
- 5. Create a new Pull Request
167
-
168
120
  Bug reports and pull requests are welcome on GitHub.
@@ -1,3 +1,3 @@
1
1
  module NullStatsd
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/null_statsd.gemspec CHANGED
@@ -6,15 +6,21 @@ require "null_statsd/version"
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "null_statsd"
8
8
  spec.version = NullStatsd::VERSION
9
- spec.authors = ["Imad Mouaddine"]
10
- spec.email = ["imouaddine@usertesting.com"]
11
- spec.summary = %q{Implements null pattern for Statsd client}
12
- spec.description = %q{Implements null pattern for Statsd client}
13
- spec.homepage = "https://github.com/usertesting/null_statsd"
9
+ spec.authors = ["Imad Mouaddine", "Perry Lee", "Bob Ziuchkovski", "Andrew Selder", "Chris DiMartino", "Justin Aiken", "Eric Mueller"]
10
+ spec.email = ["nevinera@gmail.com"]
11
+ spec.summary = %q{Implements null-object pattern for Statsd client}
12
+ spec.description = %q{Implements null-object pattern for Statsd client}
13
+ spec.homepage = "https://github.com/nevinera/null_statsd"
14
14
  spec.license = "MIT"
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|UserTesting.png)/}) }
16
- spec.bindir = "exe"
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
+
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`
18
+ .split("\x0")
19
+ .reject { |f| f.start_with?("spec") }
20
+ end
21
+
22
+ spec.bindir = "bin"
23
+ spec.executables = []
18
24
  spec.require_paths = ["lib"]
19
25
 
20
26
  spec.add_development_dependency "bundler", "~> 2.2"
metadata CHANGED
@@ -1,12 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: null_statsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Imad Mouaddine
8
+ - Perry Lee
9
+ - Bob Ziuchkovski
10
+ - Andrew Selder
11
+ - Chris DiMartino
12
+ - Justin Aiken
13
+ - Eric Mueller
8
14
  autorequire:
9
- bindir: exe
15
+ bindir: bin
10
16
  cert_chain: []
11
17
  date: 2023-12-01 00:00:00.000000000 Z
12
18
  dependencies:
@@ -66,9 +72,9 @@ dependencies:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
74
  version: 0.1.0
69
- description: Implements null pattern for Statsd client
75
+ description: Implements null-object pattern for Statsd client
70
76
  email:
71
- - imouaddine@usertesting.com
77
+ - nevinera@gmail.com
72
78
  executables: []
73
79
  extensions: []
74
80
  extra_rdoc_files: []
@@ -88,7 +94,7 @@ files:
88
94
  - lib/null_statsd/statsd.rb
89
95
  - lib/null_statsd/version.rb
90
96
  - null_statsd.gemspec
91
- homepage: https://github.com/usertesting/null_statsd
97
+ homepage: https://github.com/nevinera/null_statsd
92
98
  licenses:
93
99
  - MIT
94
100
  metadata: {}
@@ -110,5 +116,5 @@ requirements: []
110
116
  rubygems_version: 3.4.10
111
117
  signing_key:
112
118
  specification_version: 4
113
- summary: Implements null pattern for Statsd client
119
+ summary: Implements null-object pattern for Statsd client
114
120
  test_files: []