30
fluent-plugin-resque_stat @Spring_MT 13215日金曜日

fluent-plugin-resque_stat

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: fluent-plugin-resque_stat

fluent-plugin-resque_stat

@Spring_MT

13年2月15日金曜日

Page 2: fluent-plugin-resque_stat

ProfileTwitter : @Spring_MT

所属 :10xlab

http://10xlab.jp (FBページ)

13年2月15日金曜日

Page 3: fluent-plugin-resque_stat

Resque

Resque

githubで使われてるRubyベースのジョブキュー ライブラリ

バックエンドはredis

13年2月15日金曜日

Page 4: fluent-plugin-resque_stat

fluent-plugin-resque

fluentdからResqueにキューを送るoutputプラグイン

セコンさん謹製

13年2月15日金曜日

Page 5: fluent-plugin-resque_stat

fluent-plugin-resque_statResqueの状態をfluentdに投げるインプットプラグイン

pending キューの残数

processed 取り出したキューの総数

queues 登録されてるキューの名前の総数

workers キューを取り出すworkerの数

working キューを処理中のworker数

failed 失敗したキュー数

servers resqueが動いてるサーバーのhostやportの情報

environmentresque_statが動いているサーバーの RAILS_ENV or

RACK_ENV(なければdevelopmentが入る)

13年2月15日金曜日

Page 6: fluent-plugin-resque_stat

fluent-plugin-resque_statikachanで見ると

13年2月15日金曜日

Page 7: fluent-plugin-resque_stat

何でプラグインを書くのか?

13年2月15日金曜日

Page 8: fluent-plugin-resque_stat

最初はexecプラグインですまそうかと思った

13年2月15日金曜日

Page 9: fluent-plugin-resque_stat

#!/usr/bin/env ruby # encoding: UTF-8

require 'resque'Resque.redis = "127.0.0.1:6379"while Resque.info sleep 1end

13年2月15日金曜日

Page 10: fluent-plugin-resque_stat

できた!!

13年2月15日金曜日

Page 11: fluent-plugin-resque_stat

テスト!13年2月15日金曜日

Page 12: fluent-plugin-resque_stat

テスト書きますよね。。。

13年2月15日金曜日

Page 13: fluent-plugin-resque_stat

どうやって書こうかな。。。(´・ω・`)

13年2月15日金曜日

Page 14: fluent-plugin-resque_stat

テスト書きたい!

13年2月15日金曜日

Page 15: fluent-plugin-resque_stat

プラグインにしちゃえ!!

13年2月15日金曜日

Page 16: fluent-plugin-resque_stat

Fluent::Test::InputTestDriver

13年2月15日金曜日

Page 17: fluent-plugin-resque_stat

Fluent::Test::InputTestDriver

簡単に説明すると newしてインスタンス作って、runすればfluentdが動く

emitsでデータ取得すれば、あとはそれをcheckするだけ!

13年2月15日金曜日

Page 18: fluent-plugin-resque_stat

#!/usr/bin/env ruby # encoding: UTF-8

require 'fluent/test'require File.dirname(__FILE__) + '/spec_helper'

DEFAULT_CONFIG = %[ tag test host 127.0.0.1 port 6379 run_interval 1s]describe Fluent::ResqueStatInput do before { Fluent::Test.setup } context 'test_emit' do it do d = Fluent::Test::InputTestDriver.new(Fluent::ResqueStatInput).configure(DEFAULT_CONFIG) d.run do sleep 2 end emits = d.emits emits.length.should > 0 emits[0][0].should eql('test') emits[0][2].keys.should eql(['pending',]) end endend

13年2月15日金曜日

Page 19: fluent-plugin-resque_stat

13年2月15日金曜日

Page 20: fluent-plugin-resque_stat

で、よく考えたら。。。

13年2月15日金曜日

Page 21: fluent-plugin-resque_stat

execで呼び出すそのscriptにテストはありますか?

13年2月15日金曜日

Page 22: fluent-plugin-resque_stat

テストを書くためにプラグインにしてもいいのでは?

13年2月15日金曜日

Page 23: fluent-plugin-resque_stat

Rubyわかんない。。。。

13年2月15日金曜日

Page 24: fluent-plugin-resque_stat

確かに。。。。

最初はperl脳とかで書いて後で直すとかでもいいのでは?

13年2月15日金曜日

Page 25: fluent-plugin-resque_stat

テスト > 見た目

13年2月15日金曜日

Page 26: fluent-plugin-resque_stat

公開できない。。。。

13年2月15日金曜日

Page 27: fluent-plugin-resque_stat

Bundler使っていれば、githubのパスは指定できるが。。

13年2月15日金曜日

Page 28: fluent-plugin-resque_stat

$ git clone git://github.com/SpringMT/fluent-plugin-resque_stat.git test$ cd test$ gem build fluent-plugin-resque_stat.gemspec Successfully built RubyGem Name: fluent-plugin-resque_stat Version: 0.0.5 File: fluent-plugin-resque_stat-0.0.5.gem$ gem install fluent-plugin-resque_stat-0.0.5.gem Successfully installed fluent-plugin-resque_stat-0.0.5 1 gem installed Installing ri documentation for fluent-plugin-resque_stat-0.0.5... Installing RDoc documentation for fluent-plugin-resque_stat-0.0.5...

ローカルでgem install

13年2月15日金曜日

Page 29: fluent-plugin-resque_stat

テストを書くためだけにプラグインにしても良いと思います!

まとめ(一応)

13年2月15日金曜日

Page 30: fluent-plugin-resque_stat

13年2月15日金曜日