td-logger 0.3.23 → 0.3.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d56c1c7474afbeaf21ac6d5cb67c92be9e17d0f0
4
- data.tar.gz: d896adedf865360212fa5c863a0750a856ac72c4
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzExZTFkZTM1MDlkZDQzYjU3YzI1NGU2NTQwYTA1NzJhMGM2MTYyZg==
5
+ data.tar.gz: !binary |-
6
+ MWM3YWYyMmVmNzQyMmIzMTU4YjUyNWFlYWJlNTdlMTFiN2I3OGRhZQ==
5
7
  SHA512:
6
- metadata.gz: dc7fb69a448f4df5c51b89a95070b2815d32c09290cd072fda2f7eabfcfa536c91e6bf0875f2efdb3bb925bfe7884a5fcc7b19004628a4f35b1d3e67f9dd9058
7
- data.tar.gz: 1cf6fbc1329f5545f22e35a628f3d290416cb12a4651b484239c7324e235365e21c24cfb85ad81ac953bce75b2d19cd61c4d2de553d465f436bd9a6d0e2ff5ef
8
+ metadata.gz: !binary |-
9
+ MTBiMTQ2ZDEwMTJkY2ZlN2YyMjc0OTExZDYyNWY3NmZlZTMxNTBiYjhjM2Ni
10
+ MzAzZjM1ZmE5ZGY4ZTcxNTkxOTQwMTJlOWU4YzIyZThjOWExMzQxOTJiYmQ1
11
+ NzdiZjk4ZDM4MWYwZTE3NTA3Y2QwMWQ3ZjM5OGM5NjQyNzc4NDc=
12
+ data.tar.gz: !binary |-
13
+ NzQ4MGUwYWFjOGQxOTgzYzczMThlNTA3NGI1MWRiNWExMThkNDdiZTNiNjlh
14
+ NzNiYWIyOWFlN2Q4YTU5NDc1Njg1MzBmOTBhMGZjMTI0NzhmY2M3YWVjZmNm
15
+ ZTYzNWVjM2Y4NDkxZDk2NWZhNDg3MGM1MWEzZDc4OTdhMDM3YjE=
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 2.1.1
8
+ - ruby-head
9
+ - rbx
10
+
11
+ branches:
12
+ only:
13
+ - master
14
+
15
+ gemfile:
16
+ - Gemfile
17
+
18
+ script: bundle exec rake spec
19
+
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: ruby-head
23
+ - rvm: rbx
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ == 2014-11-18 version 0.3.24
2
+
3
+ * Pass all option hash's arguments to the td-client library to support
4
+ switching of API endpoints
5
+
6
+
1
7
  == 2013-09-20 version 0.3.23
2
8
 
3
9
  * Add TreasureDataLogger#flush to flush stored events immediatedly
data/README.rdoc CHANGED
@@ -4,12 +4,12 @@
4
4
 
5
5
  This gem is a *logging* *library* *for* *Treasure* *Data*. The events logged by this module will be uploaded into the cloud. There're two ways to upload:
6
6
 
7
- * 1) direct upload from applications: app -> cloud (used by default)
8
- * 2) in-direct upload from td-agent: app -> td-agent -> cloud
7
+ * *direct* *upload* *from* *applications*: app -> cloud. This option is easier to configure and setup, but it requires extra memory in the application processes. The data is logged directly in the Treasure Data Cloud through the REST APIs by leveraging the {Treasure Data Ruby Client (td-client-ruby)}[https://github.com/treasure-data/td-client-ruby] library.
8
+ * *in-direct* *upload* *from* *td-agent*: app -> td-agent -> cloud. This option requires extra steps to install the daemons into your cluster, but lowers the logging impact on your applications. The data is sent to a td-agent running either locally or remotely by leveraging the {Fluentd Ruby Logger (fluent-logger-ruby)}[https://github.com/fluent/fluent-logger-ruby/] library.
9
9
 
10
- (1) is more easy to configure and extra setup, but it requires extra memory in the application processes. (2) requires the extra installation of the daemons into your cluster, but lowers the logging impact to your applications. You can choose whether to use, by config file described laster.
10
+ The actual upload method can be selected in the config file as described below.
11
11
 
12
- == Getting Started
12
+ == Installation
13
13
 
14
14
  Add the following line to your Gemfile:
15
15
 
@@ -19,8 +19,12 @@ For Rails 2.x (not tested) without Bundler,
19
19
  edit +environment.rb+ and add to the initalizer block:
20
20
 
21
21
  config.gem "td-logger"
22
+
23
+ == Configuration
24
+
25
+ === Direct Upload
22
26
 
23
- And then add +config/treasure_data.yml+ file as followings. This is a template, which is doing the direct upload from the application processes.
27
+ This configuration enables the application to upload the events directly from the application processes (app -> cloud) through the Treasure Data REST APIs. Please add this template +config/treasure_data.yml+ file and set your apikey:
24
28
 
25
29
  development:
26
30
  apikey: "YOUR_API_KEY"
@@ -35,15 +39,45 @@ And then add +config/treasure_data.yml+ file as followings. This is a template,
35
39
  # disable logging
36
40
  test:
37
41
 
42
+ If you would wish to keep your API key as an environment variable, you can use this setting:
43
+
44
+ apikey: <% ENV['TD_API_KEY'] %>
45
+
46
+ Alternatively, one can initialize the Ruby Logger module for direct upload straight from within the application:
47
+
48
+ TreasureData::Logger.open('production',
49
+ :apikey => "YOUR_API_KEY",
50
+ :auto_create_table => true)
51
+
52
+ The hash key / value pairs specified in the second and following arguments of the 'open' function correspond to the configuration option of the underlying {td-client-ruby Ruby Client}[https://github.com/treasure-data/td-client-ruby#configuration] library.
53
+
54
+ Refer to the {Ruby SDK documentation}[http://docs.treasuredata.com/articles/ruby-sdk] for more information.
55
+
56
+ Please note that we recommend to use a write-only API key. To obtain one, please:
57
+
58
+ 1. Login into the Treasure Data Console at http://console.treasuredata.com;
59
+ 2. Visit your Profile page at http://console.treasuredata.com/users/current;
60
+ 3. Insert your password under the 'API Keys' panel;
61
+ 4. In the bottom part of the panel, under 'Write-Only API keys', either copy the API key or click on 'Generate New' and copy the new API key.
62
+
63
+ === Indirect Upload
64
+
65
+ When the 'agent' and 'tag' options are specified, the events are logged into the local td-agent daemon. Later on, the daemon uploads the event periodically to the cloud (app -> td-agent -> cloud).
66
+
67
+ This requires additional setup steps but lowers the memory and performance impact to your application processes. For the installation process, please look at our {knowledge base}[http://help.treasuredata.com/customer/portal/topics/550539-installing-td-agent/articles] page.
68
+
69
+ NOTE: This configuration is not supported on PaaS platforms.
70
+
71
+ production:
72
+ agent: "localhost:24224"
73
+ tag: td.myapp
74
+ debug_mode: false
75
+
38
76
  == Logging events
39
77
 
40
78
  You can log anytime using 'TD.event.post' method:
41
79
 
42
- class MyClass
43
- def mymethod
44
- TD.event.post('table_name', {:foo=>:bar})
45
- end
46
- end
80
+ TD.event.post('table_name', {:foo=>:bar})
47
81
 
48
82
  == Rails extension
49
83
 
@@ -64,30 +98,6 @@ In rails application, you can use 'TD.event.attribute' to set static attribute t
64
98
  end
65
99
  end
66
100
 
67
- == Configuration file
68
-
69
- === Direct Upload from Application Buffer
70
-
71
- This configuration enables the application to upload the events, directly from the application processes (app -> cloud).
72
-
73
- production:
74
- apikey: "YOUR_API_KEY"
75
- database: rails_production
76
- debug_mode: false
77
-
78
- === In-Direct Upload from td-agent
79
-
80
- When 'agent' and 'tag' options are specified, the events are logged into the local td-agent daemon. Later on, the daemon uploads the event periodically to the cloud (app -> td-agent -> cloud).
81
-
82
- This requires the additional setup to your infrastructure, but lowers the memory and performance impact to your application processes. For the installation process, please look at our {knowledge base}[http://help.treasure-data.com/kb/installing-td-agent-daemon] page.
83
-
84
- NOTE: This configuration is not supported on PaaP platforms.
85
-
86
- production:
87
- agent: "localhost:24224"
88
- tag: td.myapp
89
- debug_mode: false
90
-
91
101
  === Test mode
92
102
 
93
103
  This mode uses TestLogger of fluent-logger-ruby to store the events.
@@ -105,10 +115,8 @@ You can access the logger instance via TD.logger to check the status.
105
115
 
106
116
  == Further Readings
107
117
 
108
- If you have any problem, please ask us from the support site.
109
-
110
- * {Support Site}[http://help.treasure-data.com/]
111
- * {Knowledge Base}[http://help.treasure-data.com/kb]
118
+ If you have any problem, please consult the knowledge based and ask us on the support site:
119
+ {Support Site}[http://help.treasure-data.com].
112
120
 
113
121
  == Copyright
114
122
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.23
1
+ 0.3.24
@@ -37,14 +37,16 @@ class TreasureDataLogger < Fluent::Logger::LoggerBase
37
37
  @logger.level = ::Logger::INFO
38
38
  end
39
39
 
40
- @client = TreasureData::Client.new(apikey, :ssl => !!options[:use_ssl])
40
+ # translate :use_ssl to :ssl for backwards compatibility
41
+ options[:ssl] = options[:use_ssl] unless options[:use_ssl].nil?
42
+ @client = TreasureData::Client.new(apikey, options)
41
43
 
42
44
  @mutex = Mutex.new
43
45
  @cond = ConditionVariable.new
44
46
  @map = {} # (db,table) => buffer:String
45
47
  @queue = []
46
48
 
47
- @chunk_limit = 8*1024*1024
49
+ @chunk_limit = 8 * 1024 * 1024
48
50
  @queue_limit = 50
49
51
 
50
52
  @flush_interval = 2
@@ -1,7 +1,7 @@
1
1
  module TreasureData
2
2
  module Logger
3
3
 
4
- VERSION = '0.3.23'
4
+ VERSION = '0.3.24'
5
5
 
6
6
  end
7
7
  end
@@ -4,41 +4,63 @@ require 'spec_helper'
4
4
  describe TreasureData::Logger::TreasureDataLogger do
5
5
  context 'init' do
6
6
  it 'with apikey' do
7
- td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_1')
7
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1')
8
8
  td.instance_variable_get(:@client).api.apikey.should == 'test_1'
9
9
  td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_false
10
10
  end
11
11
 
12
12
  it 'with apikey and use_ssl' do
13
- td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_1', :use_ssl => true)
13
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :use_ssl => true)
14
14
  td.instance_variable_get(:@client).api.apikey.should == 'test_1'
15
15
  td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
16
16
  end
17
17
 
18
+ it 'with apikey and ssl' do
19
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :ssl => true)
20
+ td.instance_variable_get(:@client).api.apikey.should == 'test_1'
21
+ td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
22
+ end
23
+
24
+ it 'with apikey and HTTP endpoint' do
25
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :endpoint => "http://idontexi.st")
26
+ td.instance_variable_get(:@client).api.apikey.should == 'test_1'
27
+ td.instance_variable_get(:@client).api.instance_variable_get(:@host).should == "idontexi.st"
28
+ td.instance_variable_get(:@client).api.instance_variable_get(:@port).should == 80
29
+ td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_false
30
+ end
31
+
32
+ it 'with apikey and HTTPS endpoint' do
33
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1', :endpoint => "https://idontexi.st")
34
+ td.instance_variable_get(:@client).api.apikey.should == 'test_1'
35
+ td.instance_variable_get(:@client).api.instance_variable_get(:@host).should == "idontexi.st"
36
+ td.instance_variable_get(:@client).api.instance_variable_get(:@port).should == 443
37
+ td.instance_variable_get(:@client).api.instance_variable_get(:@ssl).should be_true
38
+ end
39
+
18
40
  it 'db config' do
19
- td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_1')
41
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_1')
20
42
  time = Time.now
21
- td.should_receive(:add).with('db1', 'table1', {:foo=>:bar, :time=>time.to_i})
22
- td.post_with_time('table1', {:foo=>:bar}, time)
43
+ td.should_receive(:add).with('db1', 'table1', {:foo => :bar, :time => time.to_i})
44
+ td.post_with_time('table1', {:foo => :bar}, time)
23
45
  end
24
46
 
25
47
  it 'fluent-logger-td compat' do
26
- td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_2')
48
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_2')
27
49
  time = Time.now
28
- td.should_receive(:add).with('overwrite', 'table1', {:foo=>:bar, :time=>time.to_i})
29
- td.post_with_time('overwrite.table1', {:foo=>:bar}, time)
50
+ td.should_receive(:add).with('overwrite', 'table1', {:foo => :bar, :time => time.to_i})
51
+ td.post_with_time('overwrite.table1', {:foo => :bar}, time)
30
52
  end
31
53
 
32
54
  ## TODO this causes real upload
33
55
  #it 'success' do
34
- # td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_3')
56
+ # td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_3')
35
57
  # td.post('valid', {}).should == true
36
58
  #end
37
59
  end
38
60
 
39
61
  context 'validate' do
40
62
  it 'validate table name' do
41
- td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey=>'test_4')
63
+ td = TreasureData::Logger::TreasureDataLogger.new('db1', :apikey => 'test_4')
42
64
  proc {
43
65
  td.post('invalid-name', {})
44
66
  }.should raise_error(RuntimeError)
@@ -51,7 +73,7 @@ describe TreasureData::Logger::TreasureDataLogger do
51
73
  end
52
74
 
53
75
  it 'validate database name' do
54
- td = TreasureData::Logger::TreasureDataLogger.new('invalid-db-name', :apikey=>'test_5')
76
+ td = TreasureData::Logger::TreasureDataLogger.new('invalid-db-name', :apikey => 'test_5')
55
77
  proc {
56
78
  td.post('table', {})
57
79
  }.should raise_error(RuntimeError)
data/td-logger.gemspec CHANGED
@@ -22,7 +22,7 @@ EOF
22
22
  gem.authors = ["Sadayuki Furuhashi"]
23
23
  #gem.email = %q{frsyuki@gmail.com}
24
24
  #gem.homepage = %q{https://github.com/treasure-data/td-logger-ruby}
25
- gem.description = %q{Treasure Data logging library for Rails}
25
+ gem.description = %q{Treasure Data logging library}
26
26
  gem.summary = gem.description
27
27
 
28
28
  gem.files = `git ls-files`.split("\n")
@@ -31,8 +31,8 @@ EOF
31
31
  gem.require_paths = ['lib']
32
32
 
33
33
  gem.add_dependency "msgpack", [">= 0.4.4", "!= 0.5.0", "!= 0.5.1", "!= 0.5.2", "!= 0.5.3", "< 0.6.0"]
34
- gem.add_dependency "td-client", "~> 0.8.51"
35
- gem.add_dependency "fluent-logger", "~> 0.4.6"
34
+ gem.add_dependency "td-client", "~> 0.8.66"
35
+ gem.add_dependency "fluent-logger", "~> 0.4.9"
36
36
  gem.add_development_dependency 'rake', '>= 0.9.2'
37
37
  gem.add_development_dependency 'rspec', '>= 2.7.0'
38
38
  end
metadata CHANGED
@@ -1,32 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.23
4
+ version: 0.3.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.4.4
20
- - - '!='
20
+ - - ! '!='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.5.0
23
- - - '!='
23
+ - - ! '!='
24
24
  - !ruby/object:Gem::Version
25
25
  version: 0.5.1
26
- - - '!='
26
+ - - ! '!='
27
27
  - !ruby/object:Gem::Version
28
28
  version: 0.5.2
29
- - - '!='
29
+ - - ! '!='
30
30
  - !ruby/object:Gem::Version
31
31
  version: 0.5.3
32
32
  - - <
@@ -36,19 +36,19 @@ dependencies:
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ! '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.4.4
42
- - - '!='
42
+ - - ! '!='
43
43
  - !ruby/object:Gem::Version
44
44
  version: 0.5.0
45
- - - '!='
45
+ - - ! '!='
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.5.1
48
- - - '!='
48
+ - - ! '!='
49
49
  - !ruby/object:Gem::Version
50
50
  version: 0.5.2
51
- - - '!='
51
+ - - ! '!='
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.5.3
54
54
  - - <
@@ -60,63 +60,64 @@ dependencies:
60
60
  requirements:
61
61
  - - ~>
62
62
  - !ruby/object:Gem::Version
63
- version: 0.8.51
63
+ version: 0.8.66
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: 0.8.51
70
+ version: 0.8.66
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: fluent-logger
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 0.4.6
77
+ version: 0.4.9
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ~>
83
83
  - !ruby/object:Gem::Version
84
- version: 0.4.6
84
+ version: 0.4.9
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - '>='
89
+ - - ! '>='
90
90
  - !ruby/object:Gem::Version
91
91
  version: 0.9.2
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: 0.9.2
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rspec
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ! '>='
104
104
  - !ruby/object:Gem::Version
105
105
  version: 2.7.0
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - '>='
110
+ - - ! '>='
111
111
  - !ruby/object:Gem::Version
112
112
  version: 2.7.0
113
- description: Treasure Data logging library for Rails
113
+ description: Treasure Data logging library
114
114
  email:
115
115
  executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
+ - .travis.yml
120
121
  - ChangeLog
121
122
  - Gemfile
122
123
  - README.rdoc
@@ -147,20 +148,20 @@ require_paths:
147
148
  - lib
148
149
  required_ruby_version: !ruby/object:Gem::Requirement
149
150
  requirements:
150
- - - '>='
151
+ - - ! '>='
151
152
  - !ruby/object:Gem::Version
152
153
  version: '0'
153
154
  required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  requirements:
155
- - - '>='
156
+ - - ! '>='
156
157
  - !ruby/object:Gem::Version
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 2.0.2
161
+ rubygems_version: 2.2.2
161
162
  signing_key:
162
163
  specification_version: 4
163
- summary: Treasure Data logging library for Rails
164
+ summary: Treasure Data logging library
164
165
  test_files:
165
166
  - spec/event_spec.rb
166
167
  - spec/rails_config_spec.rb