fluent-plugin-statsd-output 1.3.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: 3cd9b0f7773c17c051439293fcfe14ce3e60cbd3
4
- data.tar.gz: 3929c05cbb5e59c45aaddb932b884bfff9c015bc
3
+ metadata.gz: 4e5e37a292a8dd34c2aab6f4b929b43fb323bdf8
4
+ data.tar.gz: 2ac05a175f7ae0a435e26a24ef43b8734b33bc71
5
5
  SHA512:
6
- metadata.gz: 24e3bf9bc969f442d5b0fd5d0a3b8c82c5225858b34abfe357abd015a6f34522d3e08e2f440d07a5577aa56b0b2bcb22ec7906e04553e67b581418d098d6a1b8
7
- data.tar.gz: ec042e836c84efd055fa70b859e7355b7d0776bc85bd18f9d23a09f35e9fd3c009d67ad22a0877d3419e08e1fa0055168b56fb71a41f98b204c73e6b09df2087
6
+ metadata.gz: 5acbc217ced43063f185d023dfacbe6b6f4e0e50b4eb2117085ee24fa3610d765cc526629816c9c45fad68a7e7ab7b623ad601f4c4c28670442c5bd4c27e9f15
7
+ data.tar.gz: f72243486ec03cc90ef4d6cb2fdabd5be6292db137e07bf9c176cd7f5fefe91e7c92e936cf6b382751243178942eb7dedca344bf5d77d7da273bbda4f26b7954
data/.gitignore CHANGED
@@ -2,3 +2,7 @@
2
2
  *.gem
3
3
 
4
4
  spec/examples.txt
5
+
6
+ # Ignore bundler things
7
+ .bundle
8
+ vendor/
@@ -1,17 +1,29 @@
1
1
  sudo: enable
2
2
  dist: trusty
3
3
  language: ruby
4
-
5
4
  cache: bundler
6
-
7
5
  rvm:
8
- - 2.1.10
9
- - 2.2.7
10
- - 2.3.4
11
- - 2.4.1
12
-
13
- before_install:
14
- - gem install bundler --no-doc
15
-
6
+ - 2.1
7
+ - 2.2
8
+ - 2.3
9
+ - 2.4
10
+ - 2.5
11
+ - 2.6
16
12
  script: bundle exec rspec
17
-
13
+ stages:
14
+ - test
15
+ - deploy
16
+ jobs:
17
+ include:
18
+ - stage: deploy
19
+ cache: false
20
+ if: tag =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
21
+ deploy:
22
+ script: skip
23
+ provider: rubygems
24
+ api_key:
25
+ secure: hIk7N6BjLuQDNJWXEc4fZPPqcygxmvQ8IDMitY3rVaXK8+1OJEutHT/ehOhBWMjEvS70OTnCYwo6cpoQkvCmW/V6cchnt5PIBdEQ4vILEh8OP2nB72AhwxnbUOgJ2Uk+EPt1XGJPqUQ0/ZqaP6uIIYClh9s9yAxQWrkJfQrecRJF2WzwWoNVXXCl0+UuH/pcKVo5jaL56zxQTOePdEcBrm/EB3YqAmdW7wHsXnm0CaWWO5VJ/6PJHlyUW4jd5EJBYesPoAEzZwjPhUqNCcg9KqHJSce41WD6eaVHdnqyUwdZCO6OOpXTSArw1XykXX/Z4EXd2QOP/g84XG6vk10hoy9+UomHxFMtGk1AP6vMOLxn9q7zF43S/as6AQdHAnegnWYZxQpW41DSXrqgOWxIFYznR/ZmD8zJR20hgXdMgYjGZq10Wy/i8Y2SUDfojuw5OGej9OehXYQ8ZBNkdSN4U5AiGYrCBOy2WGbiDehIR/EVN5yiUS6WapcRWZ2Ia9vUDgUXHOW2OdUw5N1FR1uJ+dLr5oihD6g7nweFa6qsJb+88ecz+nby9dgL+WTVlzOzBshE8q5UcdS5959wnShHUtEZP5yQDmWn4u/haL+osEO0PRu8KLick6lYzSNO0HEEELEV76mSHI+UKVZxG8T7E+WUEoskxtRn3aomQOKvQkA=
26
+ gem: fluent-plugin-statsd-output
27
+ on:
28
+ tags: true
29
+ repo: imnotjames/fluent-plugin-statsd
@@ -1,61 +1,61 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-statsd-output (1.3.0)
4
+ fluent-plugin-statsd-output (1.4.2)
5
5
  fluentd (>= 0.10.8)
6
6
  statsd-ruby (~> 1.4)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- coderay (1.1.1)
12
- cool.io (1.5.0)
13
- diff-lcs (1.2.5)
14
- fluentd (0.14.17)
11
+ coderay (1.1.2)
12
+ cool.io (1.5.3)
13
+ diff-lcs (1.3)
14
+ dig_rb (1.0.1)
15
+ fluentd (1.3.3)
15
16
  cool.io (>= 1.4.5, < 2.0.0)
17
+ dig_rb (~> 1.0.0)
16
18
  http_parser.rb (>= 0.5.1, < 0.7.0)
17
19
  msgpack (>= 0.7.0, < 2.0.0)
18
20
  serverengine (>= 2.0.4, < 3.0.0)
19
21
  sigdump (~> 0.2.2)
20
- strptime (~> 0.1.7)
22
+ strptime (>= 0.2.2, < 1.0.0)
21
23
  tzinfo (~> 1.0)
22
24
  tzinfo-data (~> 1.0)
23
25
  yajl-ruby (~> 1.0)
24
26
  http_parser.rb (0.6.0)
25
- method_source (0.8.2)
26
- msgpack (1.1.0)
27
- power_assert (0.3.0)
28
- pry (0.10.4)
27
+ method_source (0.9.2)
28
+ msgpack (1.2.6)
29
+ power_assert (1.1.3)
30
+ pry (0.12.2)
29
31
  coderay (~> 1.1.0)
30
- method_source (~> 0.8.1)
31
- slop (~> 3.4)
32
- rspec (3.5.0)
33
- rspec-core (~> 3.5.0)
34
- rspec-expectations (~> 3.5.0)
35
- rspec-mocks (~> 3.5.0)
36
- rspec-core (3.5.1)
37
- rspec-support (~> 3.5.0)
38
- rspec-expectations (3.5.0)
32
+ method_source (~> 0.9.0)
33
+ rspec (3.8.0)
34
+ rspec-core (~> 3.8.0)
35
+ rspec-expectations (~> 3.8.0)
36
+ rspec-mocks (~> 3.8.0)
37
+ rspec-core (3.8.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-expectations (3.8.2)
39
40
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.5.0)
41
- rspec-mocks (3.5.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-mocks (3.8.0)
42
43
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.5.0)
44
- rspec-support (3.5.0)
45
- serverengine (2.0.5)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-support (3.8.0)
46
+ serverengine (2.1.0)
46
47
  sigdump (~> 0.2.2)
47
48
  sigdump (0.2.4)
48
- slop (3.6.0)
49
49
  statsd-ruby (1.4.0)
50
- strptime (0.1.9)
51
- test-unit (3.1.8)
50
+ strptime (0.2.3)
51
+ test-unit (3.2.9)
52
52
  power_assert
53
53
  thread_safe (0.3.6)
54
- tzinfo (1.2.3)
54
+ tzinfo (1.2.5)
55
55
  thread_safe (~> 0.1)
56
- tzinfo-data (1.2017.2)
56
+ tzinfo-data (1.2018.9)
57
57
  tzinfo (>= 1.0.0)
58
- yajl-ruby (1.3.0)
58
+ yajl-ruby (1.4.1)
59
59
 
60
60
  PLATFORMS
61
61
  ruby
@@ -68,4 +68,4 @@ DEPENDENCIES
68
68
  test-unit
69
69
 
70
70
  BUNDLED WITH
71
- 1.15.1
71
+ 1.17.0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 James Ward
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Fluent event to statsd plugin.
2
2
 
3
- [![Build Status](https://travis-ci.org/lingochamp/fluent-plugin-statsd.svg?branch=master)](https://travis-ci.org/lingochamp/fluent-plugin-statsd)
3
+ [![Build Status](https://travis-ci.com/imnotjames/fluent-plugin-statsd.svg?branch=master)](https://travis-ci.com/imnotjames/fluent-plugin-statsd)
4
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-statsd-output.svg)](https://badge.fury.io/rb/fluent-plugin-statsd-output)
4
5
 
5
6
  # Installation
6
7
 
@@ -8,8 +9,6 @@
8
9
  $ fluent-gem install fluent-plugin-statsd-output
9
10
  ```
10
11
 
11
- [![Gem Version](https://badge.fury.io/rb/fluent-plugin-statsd.png)](http://badge.fury.io/rb/fluent-plugin-statsd)
12
-
13
12
  # Usage
14
13
 
15
14
  ```
@@ -19,11 +18,13 @@ $ fluent-gem install fluent-plugin-statsd-output
19
18
  port 8125 # optional
20
19
  namespace a.b.c # optional
21
20
  batch_byte_size 512 # optional
21
+ sample_rate 0.9 # optional
22
22
 
23
23
  <metric>
24
24
  statsd_type timing
25
25
  statsd_key my_app.nginx.response_time
26
- statsd_key ${record['response_time']}
26
+ statsd_val ${record['response_time']}
27
+ statsd_rate 0.6 # optional
27
28
  </metric>
28
29
 
29
30
  <metric>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.4.2
@@ -4,16 +4,17 @@ $:.push File.expand_path('../lib', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-statsd-output"
6
6
  gem.description = "fluentd output filter plugin to send metrics to Esty StatsD"
7
- gem.homepage = "https://github.com/lingochamp/fluent-plugin-statsd"
7
+ gem.homepage = "https://github.com/imnotjames/fluent-plugin-statsd"
8
8
  gem.summary = gem.description
9
9
  gem.version = File.read("VERSION").strip
10
- gem.authors = ["Chris Song"]
11
- gem.email = "fakechris@gmail.com"
12
- gem.has_rdoc = false
10
+ gem.license = "MIT"
11
+ gem.authors = ["James Ward", "Chris Song"]
12
+ gem.email = "james@notjam.es"
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  gem.require_paths = ['lib']
17
+ gem.required_ruby_version = ">= 2.1.0"
17
18
 
18
19
  gem.add_dependency "fluentd", ">= 0.10.8"
19
20
  gem.add_dependency "statsd-ruby", "~> 1.4"
@@ -11,11 +11,13 @@ module Fluent
11
11
  config_param :port, :string, :default => '8125'
12
12
  config_param :namespace, :string, :default => nil
13
13
  config_param :batch_byte_size, :integer, :default => nil
14
+ config_param :sample_rate, :float, :default => 1.0
14
15
 
15
16
  config_section :metric do
16
17
  config_param :statsd_type, :string
17
18
  config_param :statsd_key, :string
18
19
  config_param :statsd_val, :string, default: nil
20
+ config_param :statsd_rate, :float, default: 1.0
19
21
  end
20
22
 
21
23
  attr_reader :statsd
@@ -57,7 +59,7 @@ module Fluent
57
59
  parser = RubyStringParser.new(record: record, tag: tag)
58
60
 
59
61
  @metrics.each do |metric|
60
- arg_names = %w{statsd_type statsd_key statsd_val}
62
+ arg_names = %w{statsd_type statsd_key statsd_val statsd_rate}
61
63
  send_to_statsd(*metric.values_at(*arg_names).map {|str| parser.parse(str) })
62
64
  end
63
65
  end
@@ -67,22 +69,24 @@ module Fluent
67
69
 
68
70
  private
69
71
 
70
- def send_to_statsd(type, key, val)
71
- log.debug([type, key, val])
72
+ def send_to_statsd(type, key, val, rate)
73
+ log.debug([type, key, val, rate])
74
+
75
+ rate = sample_rate if rate.nil?
72
76
 
73
77
  case type
74
78
  when 'timing'
75
- @statsd.timing key, val.to_f
79
+ @statsd.timing key, val.to_f, rate.to_f
76
80
  when 'gauge'
77
- @statsd.gauge key, val.to_f
81
+ @statsd.gauge key, val.to_f, rate.to_f
78
82
  when 'count'
79
- @statsd.count key, val.to_f
83
+ @statsd.count key, val.to_f, rate.to_f
80
84
  when 'set'
81
- @statsd.set key, val
85
+ @statsd.set key, val, rate.to_f
82
86
  when 'increment'
83
- @statsd.increment key
87
+ @statsd.increment key, rate.to_f
84
88
  when 'decrement'
85
- @statsd.decrement key
89
+ @statsd.decrement key, rate.to_f
86
90
  else
87
91
  raise "Invalid statsd type '#{type}'"
88
92
  end
@@ -39,9 +39,9 @@ RSpec.describe Fluent::StatsdOutput do
39
39
  it 'should call statsd with events data and correctly handle multiple placeholders' do
40
40
  allow(Statsd).to receive(:new).and_return(statsd)
41
41
 
42
- expect(statsd).to receive(:increment).with('res_code_localhost_2xx').twice.times
43
- expect(statsd).to receive(:increment).with('res_code_localhost_4xx').once.times
44
- expect(statsd).to receive(:increment).with('res_code_localhost_5xx').once.times
42
+ expect(statsd).to receive(:increment).with('res_code_localhost_2xx', 1.0).twice.times
43
+ expect(statsd).to receive(:increment).with('res_code_localhost_4xx', 1.0).once.times
44
+ expect(statsd).to receive(:increment).with('res_code_localhost_5xx', 1.0).once.times
45
45
 
46
46
  emit_events([
47
47
  {'hostname' => 'localhost', 'response_time' => 102, 'status' => '200'},
@@ -52,13 +52,13 @@ RSpec.describe Fluent::StatsdOutput do
52
52
  expect(statsd).to receive(:batch_size=).with(nil)
53
53
  expect(statsd).to receive(:batch_byte_size=).with(512)
54
54
 
55
- expect(statsd).to receive(:increment).with('res_code_2xx').twice.times
56
- expect(statsd).to receive(:increment).with('res_code_4xx').once.times
57
- expect(statsd).to receive(:increment).with('res_code_5xx').once.times
58
- expect(statsd).to receive(:timing).with('res_time', 102).ordered
59
- expect(statsd).to receive(:timing).with('res_time', 105).ordered
60
- expect(statsd).to receive(:timing).with('res_time', 112).ordered
61
- expect(statsd).to receive(:timing).with('res_time', 125).ordered
55
+ expect(statsd).to receive(:increment).with('res_code_2xx', 1.0).twice.times
56
+ expect(statsd).to receive(:increment).with('res_code_4xx', 1.0).once.times
57
+ expect(statsd).to receive(:increment).with('res_code_5xx', 1.0).once.times
58
+ expect(statsd).to receive(:timing).with('res_time', 102, 1.0).ordered
59
+ expect(statsd).to receive(:timing).with('res_time', 105, 1.0).ordered
60
+ expect(statsd).to receive(:timing).with('res_time', 112, 1.0).ordered
61
+ expect(statsd).to receive(:timing).with('res_time', 125, 1.0).ordered
62
62
 
63
63
  emit_events([
64
64
  {'response_time' => 102, 'status' => '200'},
@@ -0,0 +1,65 @@
1
+ require 'fluent/plugin/out_statsd'
2
+ require 'fluent/test'
3
+
4
+ RSpec.describe Fluent::StatsdOutput do
5
+ let(:config) do
6
+ %{
7
+ type statsd
8
+ namespace a.b.c
9
+ batch_byte_size 512
10
+
11
+ <metric>
12
+ statsd_type timing
13
+ statsd_key res_time
14
+ statsd_val ${record['response_time']}
15
+ statsd_rate 0.4
16
+ </metric>
17
+ }
18
+ end
19
+ let(:driver) { create_driver(config) }
20
+ let(:statsd) { double('statsd', increment: true,
21
+ timing: true,
22
+ flush: true,
23
+ 'namespace=' => true,
24
+ 'batch_size=' => true,
25
+ 'batch_byte_size' => true)
26
+
27
+ }
28
+ let(:time) { Time.now.utc }
29
+
30
+ before :all do
31
+ Fluent::Test.setup
32
+ end
33
+
34
+ def create_driver(conf)
35
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::StatsdOutput) {
36
+ }.configure(conf)
37
+ end
38
+
39
+ def emit_events(events)
40
+ events.each {|e| driver.emit(e, time) }
41
+ end
42
+
43
+
44
+ it 'should call statsd with events data' do
45
+ allow(Statsd).to receive(:new).and_return(statsd)
46
+
47
+ expect(statsd).to receive(:namespace=).with('a.b.c')
48
+ expect(statsd).to receive(:batch_size=).with(nil)
49
+ expect(statsd).to receive(:batch_byte_size=).with(512)
50
+
51
+ expect(statsd).to receive(:timing).with('res_time', 102, 0.4).ordered
52
+ expect(statsd).to receive(:timing).with('res_time', 105, 0.4).ordered
53
+ expect(statsd).to receive(:timing).with('res_time', 112, 0.4).ordered
54
+ expect(statsd).to receive(:timing).with('res_time', 125, 0.4).ordered
55
+
56
+ emit_events([
57
+ {'response_time' => 102, 'status' => '200'},
58
+ {'response_time' => 105, 'status' => '200'},
59
+ {'response_time' => 112, 'status' => '400'},
60
+ {'response_time' => 125, 'status' => '500'}
61
+ ])
62
+
63
+ driver.run
64
+ end
65
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-statsd-output
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
+ - James Ward
7
8
  - Chris Song
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-10-10 00:00:00.000000000 Z
12
+ date: 2019-01-23 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: fluentd
@@ -81,7 +82,7 @@ dependencies:
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  description: fluentd output filter plugin to send metrics to Esty StatsD
84
- email: fakechris@gmail.com
85
+ email: james@notjam.es
85
86
  executables: []
86
87
  extensions: []
87
88
  extra_rdoc_files: []
@@ -92,15 +93,18 @@ files:
92
93
  - AUTHORS
93
94
  - Gemfile
94
95
  - Gemfile.lock
96
+ - LICENSE
95
97
  - README.md
96
98
  - VERSION
97
- - fluent-plugin-statsd.gemspec
99
+ - fluent-plugin-statsd-output.gemspec
98
100
  - lib/fluent/plugin/out_statsd.rb
99
101
  - spec/plugin/multiple_placeholders_spec.rb
100
102
  - spec/plugin/out_statsd_spec.rb
103
+ - spec/plugin/statsd_rate_override.rb
101
104
  - spec/spec_helper.rb
102
- homepage: https://github.com/lingochamp/fluent-plugin-statsd
103
- licenses: []
105
+ homepage: https://github.com/imnotjames/fluent-plugin-statsd
106
+ licenses:
107
+ - MIT
104
108
  metadata: {}
105
109
  post_install_message:
106
110
  rdoc_options: []
@@ -110,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
114
  requirements:
111
115
  - - ">="
112
116
  - !ruby/object:Gem::Version
113
- version: '0'
117
+ version: 2.1.0
114
118
  required_rubygems_version: !ruby/object:Gem::Requirement
115
119
  requirements:
116
120
  - - ">="
@@ -118,11 +122,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
122
  version: '0'
119
123
  requirements: []
120
124
  rubyforge_project:
121
- rubygems_version: 2.6.13
125
+ rubygems_version: 2.5.2.3
122
126
  signing_key:
123
127
  specification_version: 4
124
128
  summary: fluentd output filter plugin to send metrics to Esty StatsD
125
129
  test_files:
126
130
  - spec/plugin/multiple_placeholders_spec.rb
127
131
  - spec/plugin/out_statsd_spec.rb
132
+ - spec/plugin/statsd_rate_override.rb
128
133
  - spec/spec_helper.rb