measurometer 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +51 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/lib/measurometer.rb +4 -4
- data/lib/measurometer/statsd_driver.rb +2 -2
- data/lib/measurometer/version.rb +1 -1
- data/measurometer.gemspec +1 -0
- data/spec/measurometer/statsd_driver_spec.rb +4 -0
- data/spec/measurometer_spec.rb +26 -11
- metadata +7 -7
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 145560329721f78f9988635eb5bbfcdeffd37ddaf3a5a14e2cf5891f76b94544
|
4
|
+
data.tar.gz: a59156c128ce042aeb54ef08c94c8786aeed80456a2c38ea2a892861d0cd1642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667108345d55245fed14812c07608f2fde96d6455e92d14be8dd2e56a9a298c82464703a46e42e349a670277197adc6b105239e5c89711161bc6f9cabf0efff4
|
7
|
+
data.tar.gz: c24c904cee40f2be10bbadba2aafe3c91b1e973782597678ad9e87cd7920a66a77b897c11739c961edf7c7ef10f990dc2d7ccb15adee68305c372ef0bbf5b10b
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
env:
|
6
|
+
BUNDLE_PATH: vendor/bundle
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
name: Specs
|
11
|
+
runs-on: ubuntu-18.04
|
12
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby:
|
16
|
+
- 2.7
|
17
|
+
- 2.6
|
18
|
+
- 2.5
|
19
|
+
experimental: [false]
|
20
|
+
include:
|
21
|
+
- ruby: 3.0
|
22
|
+
experimental: true
|
23
|
+
steps:
|
24
|
+
- name: Checkout
|
25
|
+
uses: actions/checkout@v2
|
26
|
+
- name: Setup Ruby
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby }}
|
30
|
+
- name: Gemfile Cache
|
31
|
+
uses: actions/cache@v2
|
32
|
+
with:
|
33
|
+
path: Gemfile.lock
|
34
|
+
key: ${{ runner.os }}-gemlock-${{ matrix.ruby }}-${{ hashFiles('Gemfile', 'measurometer.gemspec') }}
|
35
|
+
restore-keys: |
|
36
|
+
${{ runner.os }}-gemlock-${{ matrix.ruby }}-
|
37
|
+
- name: Bundle Cache
|
38
|
+
id: cache-gems
|
39
|
+
uses: actions/cache@v2
|
40
|
+
with:
|
41
|
+
path: vendor/bundle
|
42
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('Gemfile', 'Gemfile.lock', 'measurometer.gemspec') }}
|
43
|
+
restore-keys: |
|
44
|
+
${{ runner.os }}-gems-${{ matrix.ruby }}-
|
45
|
+
${{ runner.os }}-gems-
|
46
|
+
- name: Bundle Install
|
47
|
+
if: steps.cache-gems.outputs.cache-hit != 'true'
|
48
|
+
run: bundle install --jobs 4 --retry 3
|
49
|
+
- name: RSpec
|
50
|
+
continue-on-error: ${{ matrix.experimental }}
|
51
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/measurometer.rb
CHANGED
@@ -71,8 +71,8 @@ module Measurometer
|
|
71
71
|
# @param counter_path[String] under which path to push the metric
|
72
72
|
# @param by[Integer] the counter increment to apply
|
73
73
|
# @return nil
|
74
|
-
def increment_counter(counter_path, by = 1)
|
75
|
-
@drivers.each { |d| d.increment_counter(counter_path.to_s, by) }
|
74
|
+
def increment_counter(counter_path, by = 1, tags={})
|
75
|
+
@drivers.each { |d| d.increment_counter(counter_path.to_s, by, tags) }
|
76
76
|
nil
|
77
77
|
end
|
78
78
|
|
@@ -81,8 +81,8 @@ module Measurometer
|
|
81
81
|
# @param gauge_name[String] under which path to push the metric
|
82
82
|
# @param value[Integer] the absolute value of the gauge
|
83
83
|
# @return nil
|
84
|
-
def set_gauge(gauge_name, value)
|
85
|
-
@drivers.each { |d| d.set_gauge(gauge_name.to_s, value) }
|
84
|
+
def set_gauge(gauge_name, value, tags={})
|
85
|
+
@drivers.each { |d| d.set_gauge(gauge_name.to_s, value, tags) }
|
86
86
|
nil
|
87
87
|
end
|
88
88
|
end
|
@@ -17,7 +17,7 @@ module Measurometer
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def increment_counter(counter_name, by)
|
20
|
+
def increment_counter(counter_name, by, _tags={})
|
21
21
|
@statsd_client.increment(counter_name, by)
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module Measurometer
|
|
25
25
|
@statsd_client.count(key_path, value)
|
26
26
|
end
|
27
27
|
|
28
|
-
def set_gauge(gauge_name, value)
|
28
|
+
def set_gauge(gauge_name, value, _tags={})
|
29
29
|
@statsd_client.gauge(gauge_name, value)
|
30
30
|
end
|
31
31
|
|
data/lib/measurometer/version.rb
CHANGED
data/measurometer.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Measurometer::VERSION
|
9
9
|
spec.authors = ['Julik Tarkhanov']
|
10
10
|
spec.email = ['me@julik.nl']
|
11
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
11
12
|
|
12
13
|
spec.summary = 'Minimum viable API for instrumentation in libraries'
|
13
14
|
spec.description = 'Minimum viable API for instrumentation in libraries. Source metrics from your libraries to Measurometer, pick them up on the other end in the application, centrally.'
|
@@ -14,7 +14,9 @@ describe 'Measurometer::StatsdDriver' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
Measurometer.set_gauge('app.some_gauge', 42)
|
17
|
+
Measurometer.set_gauge('app.another_gauge', 43, ignore_this_tag: 2)
|
17
18
|
Measurometer.increment_counter('app.some_counter', 2)
|
19
|
+
Measurometer.increment_counter('app.another_counter', 3, ignore_this_tag: 1)
|
18
20
|
Measurometer.add_distribution_value('app.some_sample', 42)
|
19
21
|
|
20
22
|
expect(statsd).to have_received(:timing) { |block_name, timing_millis|
|
@@ -23,6 +25,8 @@ describe 'Measurometer::StatsdDriver' do
|
|
23
25
|
}
|
24
26
|
|
25
27
|
expect(statsd).to have_received(:increment).with('app.some_counter', 2)
|
28
|
+
expect(statsd).to have_received(:increment).with('app.another_counter', 3)
|
26
29
|
expect(statsd).to have_received(:count).with('app.some_sample', 42)
|
30
|
+
expect(statsd).to have_received(:gauge).with('app.another_gauge', 43)
|
27
31
|
end
|
28
32
|
end
|
data/spec/measurometer_spec.rb
CHANGED
@@ -9,13 +9,14 @@ RSpec.describe Measurometer do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
before(:each) { Measurometer.drivers.clear }
|
13
|
+
after(:each) { Measurometer.drivers.clear }
|
14
|
+
|
12
15
|
it 'has a version number' do
|
13
16
|
expect(Measurometer::VERSION).not_to be nil
|
14
17
|
end
|
15
18
|
|
16
19
|
describe '.drivers' do
|
17
|
-
before(:each) { Measurometer.drivers.clear }
|
18
|
-
after(:each) { Measurometer.drivers.clear }
|
19
20
|
let(:driver) { Object.new }
|
20
21
|
|
21
22
|
it 'allows adding and removing a driver' do
|
@@ -43,41 +44,55 @@ RSpec.describe Measurometer do
|
|
43
44
|
Measurometer.drivers << driver
|
44
45
|
result = Measurometer.add_distribution_value(:bar_intensity, 114.4)
|
45
46
|
expect(result).to be_nil
|
46
|
-
Measurometer.drivers.delete(driver)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '.increment_counter' do
|
51
51
|
it 'increments by 1 by default and converts the counter name to a String before passing it to the driver' do
|
52
52
|
driver = double
|
53
|
-
expect(driver).to receive(:increment_counter).with('barness', 1)
|
53
|
+
expect(driver).to receive(:increment_counter).with('barness', 1, {})
|
54
54
|
|
55
55
|
Measurometer.drivers << driver
|
56
56
|
result = Measurometer.increment_counter(:barness)
|
57
57
|
expect(result).to be_nil
|
58
|
-
Measurometer.drivers.delete(driver)
|
59
58
|
end
|
60
59
|
|
61
60
|
it 'passes the increment to the driver' do
|
62
61
|
driver = double
|
63
|
-
expect(driver).to receive(:increment_counter).with('barness', 123)
|
62
|
+
expect(driver).to receive(:increment_counter).with('barness', 123, {})
|
64
63
|
|
65
64
|
Measurometer.drivers << driver
|
66
65
|
result = Measurometer.increment_counter(:barness, 123)
|
67
66
|
expect(result).to be_nil
|
68
|
-
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'passes tags to the driver' do
|
70
|
+
driver = double
|
71
|
+
expect(driver).to receive(:increment_counter).with('barness', 123, tag1: 11, tag2: 22)
|
72
|
+
|
73
|
+
Measurometer.drivers << driver
|
74
|
+
result = Measurometer.increment_counter(:barness, 123, tag1: 11, tag2: 22)
|
75
|
+
expect(result).to be_nil
|
69
76
|
end
|
70
77
|
end
|
71
78
|
|
72
79
|
describe '.set_gauge' do
|
73
80
|
it 'converts the gauge name to a String before passing it to the driver' do
|
74
81
|
driver = double
|
75
|
-
expect(driver).to receive(:set_gauge).with('fooeyness', 456)
|
82
|
+
expect(driver).to receive(:set_gauge).with('fooeyness', 456, {})
|
76
83
|
|
77
84
|
Measurometer.drivers << driver
|
78
85
|
result = Measurometer.set_gauge(:fooeyness, 456)
|
79
86
|
expect(result).to be_nil
|
80
|
-
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'passes tags to the driver' do
|
90
|
+
driver = double
|
91
|
+
expect(driver).to receive(:set_gauge).with('fooeyness', 123, tag1: 11, tag2: 22)
|
92
|
+
|
93
|
+
Measurometer.drivers << driver
|
94
|
+
result = Measurometer.set_gauge(:fooeyness, 123, tag1: 11, tag2: 22)
|
95
|
+
expect(result).to be_nil
|
81
96
|
end
|
82
97
|
end
|
83
98
|
|
@@ -132,12 +147,12 @@ RSpec.describe Measurometer do
|
|
132
147
|
@distributions << [value_path, value]
|
133
148
|
end
|
134
149
|
|
135
|
-
def increment_counter(value_path, value)
|
150
|
+
def increment_counter(value_path, value, tags={})
|
136
151
|
@counters ||= []
|
137
152
|
@counters << [value_path, value]
|
138
153
|
end
|
139
154
|
|
140
|
-
def set_gauge(value_path, value)
|
155
|
+
def set_gauge(value_path, value, tags={})
|
141
156
|
@gauges ||= []
|
142
157
|
@gauges << [value_path, value]
|
143
158
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: measurometer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,10 +75,10 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".github/workflows/main.yml"
|
78
79
|
- ".gitignore"
|
79
80
|
- ".rspec"
|
80
81
|
- ".rubocop.yml"
|
81
|
-
- ".travis.yml"
|
82
82
|
- CHANGELOG.md
|
83
83
|
- CODE_OF_CONDUCT.md
|
84
84
|
- Gemfile
|
@@ -97,7 +97,7 @@ files:
|
|
97
97
|
homepage: https://github.com/WeTransfer/measurometer
|
98
98
|
licenses: []
|
99
99
|
metadata: {}
|
100
|
-
post_install_message:
|
100
|
+
post_install_message:
|
101
101
|
rdoc_options: []
|
102
102
|
require_paths:
|
103
103
|
- lib
|
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
108
|
+
version: 2.5.0
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
111
|
- - ">="
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubygems_version: 3.0.3
|
116
|
-
signing_key:
|
116
|
+
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Minimum viable API for instrumentation in libraries
|
119
119
|
test_files: []
|