magellan-log-funnel 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: f3a179d70b7b8be45d9247c5e3216336d17f7d34
4
- data.tar.gz: be0d89ab8429793a2d38d99b6f95b375573c6868
3
+ metadata.gz: c10cb12e8f780943e7fc6743276b935339165cc8
4
+ data.tar.gz: 7711739985ccf9e48a3152009aa86df2edf293be
5
5
  SHA512:
6
- metadata.gz: 154b0f07392802f3a2cacd02ec2e623ebfc3b3f19d0dfaaad07b182c915ded0eb89da43f8900023ce17e89d3519a9edd451541ad7b1a6fe3bd43eced8b829865
7
- data.tar.gz: 398bd67a2cce0efa416c9c9dc6364f22adb4d4f8d90b93d760d727203fca24ad15749fbe19c8dd8aa9fcefbb4e0db028037414f263ec61cb314e4c3fb4207e46
6
+ metadata.gz: c029faddb6a24180f423f41d9d1b6fee7fe09451ddf872f5843b4d4ccd9d77ca4632d8ddbd4eb9d9dafe05e6fceab4b695b541bbc59a35d734a04a2ff4473df6
7
+ data.tar.gz: 17a533b02c8d89a99afa5d8615c3759929e072fa528e2c8b66ffef302d06ba82f95648e3573c0d3850ed123731d7e42beb270f4c1d6fabd130e6cb8f045031b5
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "https://rubygems.org/"
2
2
 
3
+ gemspec
4
+
3
5
  group :development, :test do
4
- gem "rspec", "~> 3.0.0"
6
+ gem "rspec", "~> 3.0.0"
5
7
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,18 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ magellan-log-funnel (1.1.0)
5
+ fluent-logger (~> 0.4.9)
6
+
1
7
  GEM
2
8
  remote: https://rubygems.org/
3
9
  specs:
4
10
  diff-lcs (1.2.5)
11
+ fluent-logger (0.4.10)
12
+ msgpack (>= 0.4.4, < 0.6.0, != 0.5.3, != 0.5.2, != 0.5.1, != 0.5.0)
13
+ yajl-ruby (~> 1.0)
14
+ msgpack (0.5.11)
15
+ rake (10.4.2)
5
16
  rspec (3.0.0)
6
17
  rspec-core (~> 3.0.0)
7
18
  rspec-expectations (~> 3.0.0)
@@ -14,9 +25,13 @@ GEM
14
25
  rspec-mocks (3.0.4)
15
26
  rspec-support (~> 3.0.0)
16
27
  rspec-support (3.0.4)
28
+ yajl-ruby (1.2.1)
17
29
 
18
30
  PLATFORMS
19
31
  ruby
20
32
 
21
33
  DEPENDENCIES
34
+ bundler (~> 1.6)
35
+ magellan-log-funnel!
36
+ rake (~> 10.0)
22
37
  rspec (~> 3.0.0)
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  class LogFunnel
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@
3
3
  require "json"
4
4
  require "optparse"
5
5
  require "net/http"
6
+ require "fluent/logger"
6
7
 
7
8
  module Magellan
8
9
  class LogFunnel
@@ -43,25 +44,33 @@ module Magellan
43
44
  end
44
45
  end
45
46
 
47
+ def connect_fluentd
48
+ @logger = Fluent::Logger::FluentLogger.new("worker_logs")
49
+ end
50
+
46
51
  def now
47
52
  Time.now
48
53
  end
49
54
 
55
+ def stage_tag
56
+ @stage_tag ||= "#{@conf[:project]}.#{@conf[:stage]}"
57
+ end
58
+
50
59
  def post_msg(msg)
51
- Net::HTTP.post_form(@conf[:fluentd], json: JSON.generate({
52
- time: self.now.to_i,
60
+ @logger.post(stage_tag, {
61
+ time: self.now.to_f,
53
62
  project: @conf[:project],
54
63
  stage: @conf[:stage],
55
64
  version: @conf[:version],
56
65
  container: @conf[:container],
57
66
  message: msg
58
- }))
67
+ })
59
68
  end
60
69
 
61
70
  def run
62
71
  parse_options(@argv)
63
- @conf[:fluentd] ||= URI("http://localhost:8888")
64
- @conf[:fluentd].path = "/worker_logs.#{@conf[:project]}.#{@conf[:stage]}"
72
+
73
+ connect_fluentd
65
74
 
66
75
  if @conf[:daemon]
67
76
  Process.daemon
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.add_runtime_dependency "fluent-logger", "~> 0.4.9"
23
+
22
24
  spec.add_development_dependency "bundler", "~> 1.6"
23
25
  spec.add_development_dependency "rake", "~> 10.0"
24
26
  spec.add_development_dependency "rspec"
@@ -14,17 +14,19 @@ describe Magellan::LogFunnel do
14
14
  # stub Net::HTTP.post_form
15
15
  @now = Time.now
16
16
  allow(@funnel).to receive(:now).and_return(@now)
17
- expect(Net::HTTP).to receive(:post_form).with(URI("http://fluentd.example:8888/worker_logs.PROJECT1.STAGE1"),
18
- json: JSON.generate({
19
- time: @now.to_i,
17
+ @test_logger = Fluent::Logger::TestLogger.new
18
+ expect(Fluent::Logger::FluentLogger).to receive(:new).and_return(@test_logger)
19
+ end
20
+ it 'can handle stdout' do
21
+ expect(@funnel.run).to eql(0)
22
+ expect(@test_logger.queue.count).to eql(1)
23
+ expect(@test_logger.queue.last).to eql({
24
+ time: @now.to_f,
20
25
  project: "PROJECT1",
21
26
  stage: "STAGE1",
22
27
  version: "1.0",
23
28
  container: "CONTAINER1",
24
29
  message: "foo"
25
- }))
26
- end
27
- it 'can handle stdout' do
28
- expect(@funnel.run).to eql(0)
30
+ })
29
31
  end
30
32
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-log-funnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - t-chikanaga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluent-logger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.9
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
107
  version: '0'
94
108
  requirements: []
95
109
  rubyforge_project:
96
- rubygems_version: 2.2.2
110
+ rubygems_version: 2.4.6
97
111
  signing_key:
98
112
  specification_version: 4
99
113
  summary: log collector for magellanic cloud service.