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 +4 -4
- data/.gitignore +5 -9
- data/README.md +48 -96
- data/lib/null_statsd/version.rb +1 -1
- data/null_statsd.gemspec +14 -8
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a03895a65a1b40080b50230a67e3d78d1b2feebe4440a955fc7c5643d2934f0
|
4
|
+
data.tar.gz: ab2409351d7d8e46108689b7732fc6ed0e71e2b67cd7bbe80e9cb3cf88f0ceea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1207c5fb60d4a4e39ecbffdf84ec0894e4e8fb7c693e08675164ec10a7e467556650dc1bd97791ed5859398c6dd0405d09a3f5d7dea631cab82200dd795fdd8
|
7
|
+
data.tar.gz: f201c0a149a66a10eb21b05feb63b069c0f6d27ea4816d7945e0fddf8b941d46b398a43899a2240b7d0d9bdd26f8a49ad1f753c41ca398713015bdc3929e9d8c
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# NullStatsd
|
2
2
|
|
3
|
-
NullStatsd is a [
|
4
|
-
|
5
|
-
stubbed Statsd
|
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
|
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"]
|
31
|
-
Statsd.new(
|
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:
|
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
|
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
|
62
|
+
### Supported Calls
|
55
63
|
|
56
64
|
```ruby
|
57
|
-
|
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
|
-
|
68
|
+
statsd.increment "media.book.consumed", genre: "horror"
|
69
|
+
# => [NullStatsD a.co:42] Incrementing media.book.consumed with opts {"genre":"horror"}
|
61
70
|
|
62
|
-
|
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
|
-
|
65
|
-
|
66
|
-
```
|
74
|
+
statsd.count "responses", 3
|
75
|
+
# => [NullStatsD a.co:42] Increasing responses by 3
|
67
76
|
|
68
|
-
|
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
|
-
|
80
|
+
statsd.histogram "media.book.lent.hour", 42
|
81
|
+
# => [NullStatsD a.co:42] Logging histogram media.book.lent.hour -> 42
|
71
82
|
|
72
|
-
|
73
|
-
|
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
|
-
|
86
|
+
statsd.set "media.book.lent", 10_000_000
|
87
|
+
# => [NullStatsD a.co:42] Setting media.book.lent to 10000000
|
85
88
|
|
86
|
-
|
89
|
+
statsd.service_check "door.locked", "ok"
|
90
|
+
# => [NullStatsD a.co:42] Service check door.locked: ok
|
87
91
|
|
88
|
-
|
89
|
-
|
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
|
-
|
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
|
-
|
100
|
+
statsd.close
|
101
|
+
# => [NullStatsD a.co:42] Close called
|
145
102
|
|
146
|
-
|
147
|
-
|
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
|
-
|
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.
|
data/lib/null_statsd/version.rb
CHANGED
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 = ["
|
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/
|
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
|
-
|
16
|
-
spec.
|
17
|
-
|
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.
|
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:
|
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
|
-
-
|
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/
|
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: []
|