fluent-plugin-sixpack 0.1.0 → 0.2.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: 7de3147cdbfecd0b93439d12c370b6db923dcbcc
4
- data.tar.gz: cab2e034439051a97ce950949801cf70b3a159f3
3
+ metadata.gz: b91c9d69489bb8e18414ab354bbf69c356d3056e
4
+ data.tar.gz: 335fe12f805ca1e5564c80980218ce6086d43a28
5
5
  SHA512:
6
- metadata.gz: 68cdd62f01db47a775f91ef2ed17e8b1137e05933aa8bbaa55d9934c85963fed5ccb73b171db2ca733d067dccbac78f6dea20d3b09f0623d1bbff00df95eab4c
7
- data.tar.gz: 89f4a0ef7f4f3271f5aca1e8d82df38dc6d0f7b882e8d5222ad4c6ec982c325d766a153d43db3975a2270cbb0e02e49214a5849f1624086f239fe0bc0b3dff31
6
+ metadata.gz: f1d16582d6f120cc60a947d627560799c2cedb9e4e0c150812323cb7db228209e742a0206c23456850de78ceff3c5697dcfb5af048ec61e9a82c9786bd1fc905
7
+ data.tar.gz: 08ee9c0b3bd8410c18bd0081e9a6d5a9cd9873b97323cb2ea56f5c1075d820f7c6dfb4c5a940896439e60801024aaf81feeaf5adfca0a9a708a52dc4c73386c6
data/README.md CHANGED
@@ -21,6 +21,8 @@ For messages to participate A/B test such as:
21
21
  Or messages to convert A/B test such as
22
22
 
23
23
  tag:your.arbitrary.tag {"record_type":"convert", "experiment":"header-color", "client_id":"ID-0000-0001"}
24
+ #you can also specify kpi id
25
+ tag:your.arbitrary.tag {"record_type":"convert", "experiment":"header-color", "client_id":"ID-0000-0001", "kpi":"conversion-100dollar"}
24
26
 
25
27
  Configuration example for graphs in sixpack with POST api url `http://sixpack:5000/(participate|convert)`. You must set this parameter.
26
28
 
@@ -42,6 +44,7 @@ You can change assignment between param keys and values, with using settings bel
42
44
  - `key_alternative, :default => 'alternative'`
43
45
  - `key_client_id, :default => 'client_id'`
44
46
  - `key_record_type, :default => 'record_type'`
47
+ - `key_kpi , :default => 'kpi'`
45
48
 
46
49
  ### Configuration parameters
47
50
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-sixpack"
5
- gem.version = "0.1.0"
5
+ gem.version = "0.2.0"
6
6
  gem.authors = ["Naoki AINOYA"]
7
7
  gem.email = ["ainonic@gmail.com"]
8
8
  gem.summary = %q{Fluentd output plugin to post numbers to sixpack (by seatgeek)}
@@ -11,9 +11,10 @@ class Fluent::SixpackOutput < Fluent::Output
11
11
  config_param :sixpackapi_url, :string
12
12
  config_param :key_experiment, :default => 'experiment'
13
13
  config_param :key_alternatives, :default => 'alternatives'
14
- config_param :key_alternative, :default => 'alternative'
14
+ config_param :key_alternative, :default => 'alternative'
15
15
  config_param :key_client_id, :default => 'client_id'
16
16
  config_param :key_record_type, :default => 'record_type'
17
+ config_param :key_kpi, :string, :default => 'kpi'
17
18
 
18
19
  config_param :user_agent, :default => 'user_agent'
19
20
  config_param :ip_address, :default => 'ip_address'
@@ -135,16 +136,23 @@ class Fluent::SixpackOutput < Fluent::Output
135
136
  :client_id => record[@key_client_id],
136
137
  })
137
138
  when 'convert'
138
- return sixpack_path, URI.encode_www_form({
139
- :experiment => record[@key_experiment],
140
- :client_id => record[@key_client_id],
141
- })
139
+ return sixpack_path, form_encode_params_convert(record)
142
140
  else
143
141
  log.warn 'failed to map sixpack path and query'
144
142
  raise
145
143
  end
146
144
  end
147
145
 
146
+ def form_encode_params_convert(record)
147
+ params = {
148
+ :experiment => record[@key_experiment],
149
+ :client_id => record[@key_client_id],
150
+ }
151
+ params.merge!({:kpi => record[@key_kpi]}) if(record[@key_kpi])
152
+
153
+ return URI.encode_www_form(params)
154
+ end
155
+
148
156
  def post_request(event)
149
157
  uri = URI.parse(@sixpackapi_url)
150
158
  uri.path, uri.query = map_sixpack_path_with_query(event[:record])
@@ -38,6 +38,21 @@ class SixpackOutputTest < Test::Unit::TestCase
38
38
  assert_equal 'experiment_test_convert', @posted[0][:experiment]
39
39
  end
40
40
 
41
+ def test_convert_with_kpi
42
+ d = create_driver(CONFIG_NON_KEEPALIVE, 'test.metrics')
43
+ d.emit({'record_type' => 'convert',
44
+ 'client_id' => "0000-0000-0000-0000",
45
+ 'kpi' => "kpi",
46
+ 'experiment' => 'experiment_test_convert'})
47
+ sleep 0.5 # wait internal posting thread loop
48
+
49
+ assert_equal 1, @posted.size
50
+
51
+ assert_equal '0000-0000-0000-0000', @posted[0][:client_id]
52
+ assert_equal 'experiment_test_convert', @posted[0][:experiment]
53
+ assert_equal 'kpi', @posted[0][:kpi]
54
+ end
55
+
41
56
  def test_invalid_type
42
57
  d = create_driver(CONFIG_NON_KEEPALIVE, 'test.metrics')
43
58
  d.emit({'record_type' => 'invalid_type',
@@ -177,20 +192,24 @@ class SixpackOutputTest < Test::Unit::TestCase
177
192
  # ok, authorization not required
178
193
  end
179
194
 
180
- @posted.push({
195
+ post_param = {
181
196
  :alternatives=> req.query["alternatives"],
182
197
  :alternative => req.query["alternative"],
183
198
  :client_id => req.query["client_id"],
184
199
  :experiment => req.query["experiment"]
185
- })
200
+ }
201
+
202
+ @posted.push(post_param)
186
203
 
187
204
  res.status = 200
188
205
  }
189
206
  srv.mount_proc('/convert') { |req,res|
190
- @posted.push({
207
+ post_param = {
191
208
  :client_id => req.query["client_id"],
192
209
  :experiment => req.query["experiment"]
193
- })
210
+ }
211
+ post_param.merge!({:kpi => req.query["kpi"]}) if req.query["kpi"]
212
+ @posted.push(post_param)
194
213
  res.status = 200
195
214
  }
196
215
  srv.mount_proc('/') { |req,res|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sixpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoki AINOYA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-05 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -85,7 +85,7 @@ files:
85
85
  - fluent-plugin-sixpack.gemspec
86
86
  - lib/fluent/plugin/out_sixpack.rb
87
87
  - test/helper.rb
88
- - test/plugin/test_out_growthforecast.rb
88
+ - test/plugin/test_out_sixpack.rb
89
89
  homepage: https://github.com/ainoya/fluent-plugin-sixpack
90
90
  licenses:
91
91
  - APLv2
@@ -112,4 +112,5 @@ specification_version: 4
112
112
  summary: Fluentd output plugin to post numbers to sixpack (by seatgeek)
113
113
  test_files:
114
114
  - test/helper.rb
115
- - test/plugin/test_out_growthforecast.rb
115
+ - test/plugin/test_out_sixpack.rb
116
+ has_rdoc: