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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df51b60bd2fe7c7c02cbd31be5729b6ecf73f4bd648f1fb423bc493510555215
4
- data.tar.gz: a92627ad8a3e285b5848a2295cc0ae5fd76082adc26dcf927aaed7314fe34013
3
+ metadata.gz: 145560329721f78f9988635eb5bbfcdeffd37ddaf3a5a14e2cf5891f76b94544
4
+ data.tar.gz: a59156c128ce042aeb54ef08c94c8786aeed80456a2c38ea2a892861d0cd1642
5
5
  SHA512:
6
- metadata.gz: 847d3e71f92b9920736f8ab9f978fe153663368edbf4b78e2bee3d7063e97a18157323f2ff8fcaa3c5931cd4a07075f0cd5dc826803f44789485b4a4fd7db734
7
- data.tar.gz: 570a3a98e128e02b2f7b1c6e4af64d4e5e78d8ad5a767fb401df9dc8e43212417716409c88049c3655be55be9b075eb6f8e7df78a5e92bfb9de835865289aef1
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
@@ -10,3 +10,5 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+
14
+ .ruby-version
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.2.0
2
+
3
+ * Adds support to set a tag on Appsignal in methods `increment_counter` and `set_gauge`
4
+
1
5
  # 1.1.1
2
6
 
3
7
  * Automatically convert metric and instrumentation block names to Strings, since i.e.
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
 
@@ -1,3 +1,3 @@
1
1
  module Measurometer
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
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
@@ -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
- Measurometer.drivers.delete(driver)
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
- Measurometer.drivers.delete(driver)
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.1.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: 2020-05-15 00:00:00.000000000 Z
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: '0'
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: []
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.3
5
- before_install: gem install bundler -v 1.14.6