fluent-plugin-statsd 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d861ad576fa7d81028e037b0e3b84b7d45fe65c0
4
+ data.tar.gz: 2e3a1e1453a42cc55a03a473500883193f6d2b16
5
+ SHA512:
6
+ metadata.gz: 238ec1f8700a33abb3c86469a5f1022b77b715ea63d346b97ea14e392f3bc751e7066bb5f2923b031b3288767777b8afa2bf19990a72b3fba33c81507ae5b69f
7
+ data.tar.gz: f0a1645900849fc68223d92bb653ac5930619240c1a53da722e35fbeb824b01fd6ddc2a1b89a67d0ad625dabc9e5917db38d8a0a420f9055fa6af6a412f10d0b
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ Chris Song <fakechris _at_ gmail.com>
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ gem "statsd-ruby"
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Fluent event to statsd plugin.
2
+
3
+ # Installation
4
+
5
+ ```
6
+ $ fluent-gem install fluent-plugin-statsd
7
+ ```
8
+
9
+ # Usage
10
+
11
+ ```
12
+ <match statsd>
13
+ type statsd
14
+ host localhost # optional
15
+ port 8125# optional
16
+ </match>
17
+ ```
18
+
19
+ # Copyright
20
+
21
+ Copyright (c) 2014- Chris Song
22
+
23
+ # License
24
+
25
+ Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |test|
7
+ test.libs << 'lib' << 'test'
8
+ test.test_files = FileList['test/plugin/*.rb']
9
+ test.verbose = true
10
+ end
11
+
12
+ task :coverage do |t|
13
+ ENV['SIMPLE_COV'] = '1'
14
+ Rake::Task["test"].invoke
15
+ end
16
+
17
+ task :default => [:build]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "fluent-plugin-statsd"
6
+ gem.description = "fluentd statsd plugin"
7
+ gem.homepage = "https://github.com/fakechris/fluent-plugin-statsd"
8
+ gem.summary = gem.description
9
+ gem.version = File.read("VERSION").strip
10
+ gem.authors = ["Chris Song"]
11
+ gem.email = "fakechris@gmail.com"
12
+ gem.has_rdoc = false
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ gem.require_paths = ['lib']
17
+
18
+ gem.add_dependency "fluentd", ">= 0.10.8"
19
+
20
+ gem.add_development_dependency "rake", ">= 0.9.2"
21
+ gem.add_development_dependency "statsd-ruby", ">=1.2.1"
22
+ end
@@ -0,0 +1,50 @@
1
+ require 'statsd-ruby'
2
+
3
+ module Fluent
4
+ class StatsdOutput < BufferedOutput
5
+ Fluent::Plugin.register_output('statsd', self)
6
+
7
+ config_param :flush_interval, :time, :default => 1
8
+ config_param :host, :string, :default => 'localhost'
9
+ config_param :port, :string, :default => '8125'
10
+
11
+ attr_reader :statsd
12
+
13
+ def initialize
14
+ super
15
+ end
16
+
17
+ def configure(conf)
18
+ super
19
+ @statsd = Statsd.new(host, port)
20
+ end
21
+
22
+ def start
23
+ super
24
+ end
25
+
26
+ def shutdown
27
+ super
28
+ end
29
+
30
+ def format(tag, time, record)
31
+ record.to_msgpack
32
+ end
33
+
34
+ def write(chunk)
35
+ chunk.msgpack_each {|record|
36
+ if statsd_type = record['statsd_type']
37
+ case statsd_type
38
+ when 'timing'
39
+ @statsd.timing record['statsd_key'], record['statsd_timing'].to_f
40
+ when 'guage'
41
+ @statsd.guage record['statsd_key'], record['statsd_gauge'].to_f
42
+ when 'increment'
43
+ @statsd.increment record['statsd_key']
44
+ end
45
+ end
46
+ }
47
+ end
48
+
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ require 'fluent/plugin/out_statsd'
2
+ require 'statsd-ruby'
3
+
4
+ class StatsdOutputTest < Test::Unit::TestCase
5
+ def setup
6
+ super
7
+ Fluent::Test.setup
8
+ @now = Time.now
9
+ end
10
+
11
+ def treedown
12
+ end
13
+
14
+ CONFIG = %[
15
+ type statsd
16
+ ]
17
+
18
+ def create_driver(conf = CONFIG)
19
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::StatsdOutput) {
20
+ }.configure(conf)
21
+ end
22
+
23
+ def test_write
24
+ d = create_driver
25
+ time = Time.at(@now.to_i).utc
26
+ d.emit({ :stastd_type => 'timing', :statsd_key => 'test.statsd.t', :statsd_timing => 100 }, time)
27
+ d.emit({ :stastd_type => 'guage', :statsd_key => 'test.statsd.g', :statsd_gauge => 102 }, time)
28
+ d.emit({ :stastd_type => 'increment', :statsd_key => 'test.statsd.i'}, time)
29
+
30
+ d.run
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-statsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Song
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.8
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.8
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: statsd-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.1
55
+ description: fluentd statsd plugin
56
+ email: fakechris@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - AUTHORS
62
+ - Gemfile
63
+ - README.md
64
+ - Rakefile
65
+ - VERSION
66
+ - fluent-plugin-statsd.gemspec
67
+ - lib/fluent/plugin/out_statsd.rb
68
+ - test/plugin/out_statsd.rb
69
+ homepage: https://github.com/fakechris/fluent-plugin-statsd
70
+ licenses: []
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.2.2
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: fluentd statsd plugin
92
+ test_files:
93
+ - test/plugin/out_statsd.rb