netflix-spectator-rb 0.1.3 → 0.2.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 +1 -0
- data/.travis.yml +0 -1
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/lib/spectator.rb +2 -0
- data/lib/spectator/atomic_number.rb +2 -0
- data/lib/spectator/clock.rb +2 -0
- data/lib/spectator/counter.rb +2 -0
- data/lib/spectator/distribution_summary.rb +4 -1
- data/lib/spectator/gauge.rb +2 -0
- data/lib/spectator/http.rb +2 -0
- data/lib/spectator/measure.rb +2 -0
- data/lib/spectator/meter_id.rb +2 -0
- data/lib/spectator/registry.rb +18 -18
- data/lib/spectator/timer.rb +4 -1
- data/lib/spectator/version.rb +3 -1
- data/netflix-spectator-rb.gemspec +2 -1
- metadata +4 -5
- data/Gemfile.lock +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7461adb6e33f0392ecc42b7752f0c0bd0fb0dc5ab45f14d4415ee95937b08fc4
|
4
|
+
data.tar.gz: dc35ff0a6588a74d87b4b2cb8f4ef42118bea937c659c626c4945eea8c795920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15a0f31a565eee773ba07d0e36b081b121d982e71f4650d2a2c57b80fc999f7c3c41b129dcd5f9a79f35ffbb4370cc937a98e6fbb9c978f5c524653092bfc93b
|
7
|
+
data.tar.gz: 89cccad50469ed909cea9f85a80187053f20431e04ce2a2f942d1f096e11b6c872c9d6033e1f2107c8edacaa76fb865e2f8c705829f7f96e025ec3d989d210f4
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/spectator.rb
CHANGED
data/lib/spectator/clock.rb
CHANGED
data/lib/spectator/counter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spectator/atomic_number'
|
2
4
|
|
3
5
|
module Spectator
|
@@ -19,7 +21,8 @@ module Spectator
|
|
19
21
|
|
20
22
|
# Update the statistics kept by the summary with the specified amount.
|
21
23
|
def record(amount)
|
22
|
-
return if amount
|
24
|
+
return if amount.negative?
|
25
|
+
|
23
26
|
@count.add_and_get(1)
|
24
27
|
@total_amount.add_and_get(amount)
|
25
28
|
@total_sq.add_and_get(amount * amount)
|
data/lib/spectator/gauge.rb
CHANGED
data/lib/spectator/http.rb
CHANGED
data/lib/spectator/measure.rb
CHANGED
data/lib/spectator/meter_id.rb
CHANGED
data/lib/spectator/registry.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spectator/clock'
|
2
4
|
require 'spectator/counter'
|
3
5
|
require 'spectator/distribution_summary'
|
@@ -9,7 +11,9 @@ require 'spectator/timer'
|
|
9
11
|
module Spectator
|
10
12
|
# Registry to manage a set of meters
|
11
13
|
class Registry
|
12
|
-
|
14
|
+
DEFAULT_BATCH_SIZE = 10_000
|
15
|
+
|
16
|
+
attr_reader :config, :clock, :publisher, :common_tags, :batch_size
|
13
17
|
|
14
18
|
# Initialize the registry using the given config, and clock
|
15
19
|
# The default clock is the SystemClock
|
@@ -20,7 +24,7 @@ module Spectator
|
|
20
24
|
# :uri the endpoint for the aggregator service
|
21
25
|
def initialize(config, clock = SystemClock.new)
|
22
26
|
@config = config
|
23
|
-
@batch_size = config[:batch_size] ||
|
27
|
+
@batch_size = config[:batch_size] || DEFAULT_BATCH_SIZE
|
24
28
|
@clock = clock
|
25
29
|
@meters = {}
|
26
30
|
@common_tags = to_symbols(config[:common_tags]) || {}
|
@@ -163,7 +167,7 @@ module Spectator
|
|
163
167
|
|
164
168
|
@should_stop = true
|
165
169
|
Spectator.logger.info('Stopping spectator')
|
166
|
-
@publish_thread
|
170
|
+
@publish_thread&.kill
|
167
171
|
|
168
172
|
@started = false
|
169
173
|
Spectator.logger.info('Sending last batch of metrics before exiting')
|
@@ -172,31 +176,27 @@ module Spectator
|
|
172
176
|
|
173
177
|
ADD_OP = 0
|
174
178
|
MAX_OP = 10
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
totalTime: ADD_OP,
|
179
|
-
totalOfSquares: ADD_OP,
|
180
|
-
percentile: ADD_OP,
|
181
|
-
max: MAX_OP,
|
182
|
-
gauge: MAX_OP,
|
183
|
-
activeTasks: MAX_OP,
|
184
|
-
duration: MAX_OP }.freeze
|
179
|
+
COUNTER_STATS = %i[count totalAmount totalTime
|
180
|
+
totalOfSquares percentile].freeze
|
181
|
+
|
185
182
|
# Get the operation to be used for the given Measure
|
186
183
|
# Gauges are aggregated using MAX_OP, counters with ADD_OP
|
187
184
|
def op_for_measurement(measure)
|
188
|
-
stat = measure.id.tags.fetch(:statistic,
|
189
|
-
|
185
|
+
stat = measure.id.tags.fetch(:statistic, '')
|
186
|
+
if COUNTER_STATS.include? stat
|
187
|
+
ADD_OP
|
188
|
+
else
|
189
|
+
MAX_OP
|
190
|
+
end
|
190
191
|
end
|
191
192
|
|
192
193
|
# Gauges are sent if they have a value
|
193
194
|
# Counters if they have a number of increments greater than 0
|
194
195
|
def should_send(measure)
|
195
196
|
op = op_for_measurement(measure)
|
196
|
-
return measure.value
|
197
|
-
return !measure.value.nan? if op == MAX_OP
|
197
|
+
return measure.value.positive? if op == ADD_OP
|
198
198
|
|
199
|
-
|
199
|
+
!measure.value.nan?
|
200
200
|
end
|
201
201
|
|
202
202
|
# Build a string table from the list of measurements
|
data/lib/spectator/timer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spectator/atomic_number'
|
2
4
|
require 'spectator/clock'
|
3
5
|
|
@@ -20,7 +22,8 @@ module Spectator
|
|
20
22
|
# Update the statistics kept by this timer. If the amount of nanoseconds
|
21
23
|
# passed is negative, the value will be ignored.
|
22
24
|
def record(nanos)
|
23
|
-
return if nanos
|
25
|
+
return if nanos.negative?
|
26
|
+
|
24
27
|
@count.add_and_get(1)
|
25
28
|
@total_time.add_and_get(nanos)
|
26
29
|
@total_sq.add_and_get(nanos * nanos)
|
data/lib/spectator/version.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -23,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
23
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
25
|
spec.require_paths = ['lib']
|
25
26
|
|
26
|
-
spec.add_development_dependency 'bundler', '~>
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
28
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
29
30
|
spec.add_development_dependency 'rubocop', '~> 0.55'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netflix-spectator-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Muino
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- ".rubocop.yml"
|
79
79
|
- ".travis.yml"
|
80
80
|
- Gemfile
|
81
|
-
- Gemfile.lock
|
82
81
|
- LICENSE
|
83
82
|
- OSSMETADATA
|
84
83
|
- README.md
|
data/Gemfile.lock
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
netflix-spectator-rb (0.1.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.0)
|
10
|
-
docile (1.3.0)
|
11
|
-
json (2.1.0)
|
12
|
-
minitest (5.11.3)
|
13
|
-
parallel (1.12.1)
|
14
|
-
parser (2.5.1.0)
|
15
|
-
ast (~> 2.4.0)
|
16
|
-
powerpack (0.1.1)
|
17
|
-
rainbow (3.0.0)
|
18
|
-
rake (10.5.0)
|
19
|
-
rubocop (0.55.0)
|
20
|
-
parallel (~> 1.10)
|
21
|
-
parser (>= 2.5)
|
22
|
-
powerpack (~> 0.1)
|
23
|
-
rainbow (>= 2.2.2, < 4.0)
|
24
|
-
ruby-progressbar (~> 1.7)
|
25
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
26
|
-
ruby-progressbar (1.9.0)
|
27
|
-
simplecov (0.16.1)
|
28
|
-
docile (~> 1.1)
|
29
|
-
json (>= 1.8, < 3)
|
30
|
-
simplecov-html (~> 0.10.0)
|
31
|
-
simplecov-html (0.10.2)
|
32
|
-
unicode-display_width (1.3.2)
|
33
|
-
|
34
|
-
PLATFORMS
|
35
|
-
ruby
|
36
|
-
|
37
|
-
DEPENDENCIES
|
38
|
-
bundler (~> 1.16)
|
39
|
-
minitest (~> 5.0)
|
40
|
-
netflix-spectator-rb!
|
41
|
-
rake (~> 10.0)
|
42
|
-
rubocop (~> 0.55)
|
43
|
-
simplecov
|
44
|
-
|
45
|
-
BUNDLED WITH
|
46
|
-
1.16.1
|