fluent-plugin-indicative 0.1.6 → 0.1.7
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 +4 -4
- data/fluent-plugin-indicative.gemspec +1 -1
- data/lib/fluent/plugin/out_indicative.rb +13 -5
- data/test/plugin/test_out_indicative.rb +52 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d91e885b3638a46fae8fd381a7dcbedcc054d43e11f8c2e99eac1c691c9544
|
4
|
+
data.tar.gz: 90152aadeaedcb61989ce25e0bbdf682098c0e6621e102447352a50f98522083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d9539774cac95d2b87ee221cdbde3f757e9637258723fe1a6d6b85dc3cf43aff52cd31755c9f89e2558eaed9bcac3082273da446849c0c135482c5f974ca73
|
7
|
+
data.tar.gz: d12cd7b41f43304cae2cfea5f7343e7b55bf9256f9e84ebd7d51ce638ef5d5b566f9fa9ad9dd2b2aefe243d91359392de73f550c4def63ecb0fbf515f9b83f4e
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-indicative"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.7"
|
7
7
|
s.authors = ["Sam Millar"]
|
8
8
|
s.email = ["sam@millar.io"]
|
9
9
|
s.homepage = "https://github.com/millar/fluent-plugin-indicative"
|
@@ -5,8 +5,6 @@ require 'uri'
|
|
5
5
|
|
6
6
|
require 'fluent/plugin/output'
|
7
7
|
|
8
|
-
BATCH_SIZE = 15
|
9
|
-
|
10
8
|
|
11
9
|
def flatten_hash(hash)
|
12
10
|
hash.each_with_object({}) do |(k, v), h|
|
@@ -14,7 +12,16 @@ def flatten_hash(hash)
|
|
14
12
|
flatten_hash(v).map do |h_k, h_v|
|
15
13
|
h["#{k}.#{h_k}"] = h_v
|
16
14
|
end
|
17
|
-
elsif
|
15
|
+
elsif v.is_a? Array
|
16
|
+
# Indicative doesn't support arrays so we use the value of the array as a key and set it to true
|
17
|
+
v.each do |item|
|
18
|
+
if item.is_a?(Hash) && item.has_key?("key") && item.has_key?("value")
|
19
|
+
h["#{k}.#{item["key"]}"] = item["value"]
|
20
|
+
else
|
21
|
+
h["#{k}.#{item}"] = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
18
25
|
h[k] = v
|
19
26
|
end
|
20
27
|
end
|
@@ -26,12 +33,13 @@ class Fluent::Plugin::IndicativeOutput < Fluent::Plugin::Output
|
|
26
33
|
|
27
34
|
config_param :api_key, :string, secret: true
|
28
35
|
config_param :api_url, :string, default: 'https://api.indicative.com/service/event/batch'
|
36
|
+
config_param :batch_size, :integer, default: 15
|
29
37
|
config_param :event_name_key, :string
|
30
38
|
config_param :event_time_key, :string
|
31
39
|
config_param :event_unique_id_keys, :array, value_type: :string
|
32
40
|
|
33
41
|
def process(tag, es)
|
34
|
-
es.each_slice(
|
42
|
+
es.each_slice(@batch_size) do |events|
|
35
43
|
send_events(events.map {|time, record| record})
|
36
44
|
end
|
37
45
|
end
|
@@ -41,7 +49,7 @@ class Fluent::Plugin::IndicativeOutput < Fluent::Plugin::Output
|
|
41
49
|
chunk.each do |time, record|
|
42
50
|
records << record
|
43
51
|
end
|
44
|
-
records.each_slice(
|
52
|
+
records.each_slice(@batch_size) do |events|
|
45
53
|
send_events(events)
|
46
54
|
end
|
47
55
|
end
|
@@ -77,4 +77,56 @@ class IndicativeOutputTest < Test::Unit::TestCase
|
|
77
77
|
assert_equal 0, events.length
|
78
78
|
assert_requested :post, d.instance.api_url, times: 1
|
79
79
|
end
|
80
|
+
|
81
|
+
def test_array_transformation
|
82
|
+
d = create_driver(STREAM_CONFIG)
|
83
|
+
stub_request(:any, d.instance.api_url)
|
84
|
+
d.run(default_tag: 'test') do
|
85
|
+
d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'experiments': ['a', 'c']})
|
86
|
+
end
|
87
|
+
events = d.events
|
88
|
+
assert_equal 0, events.length
|
89
|
+
assert_requested :post, d.instance.api_url,
|
90
|
+
headers: {'Content-Type' => 'application/json'}, body: {
|
91
|
+
'apiKey' => 'INDICATIVE_API_KEY',
|
92
|
+
'events' => [{
|
93
|
+
'eventName' => 'screen_view',
|
94
|
+
'eventUniqueId' => 'a3bd2',
|
95
|
+
'properties' => {
|
96
|
+
'event_name' => 'screen_view',
|
97
|
+
'created_at' => '2015-01-01T10:00:00.000Z',
|
98
|
+
'session_id' => 'a3bd2',
|
99
|
+
'experiments.a' => true,
|
100
|
+
'experiments.c' => true
|
101
|
+
},
|
102
|
+
'eventTime' => '2015-01-01T10:00:00+00:00'
|
103
|
+
}]
|
104
|
+
}.to_json, times: 1
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_key_value_object_transformation
|
108
|
+
d = create_driver(STREAM_CONFIG)
|
109
|
+
stub_request(:any, d.instance.api_url)
|
110
|
+
d.run(default_tag: 'test') do
|
111
|
+
d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'experiments': [{'key': 'a', 'value': 1}, {'key': 'b', 'value': 2}]})
|
112
|
+
end
|
113
|
+
events = d.events
|
114
|
+
assert_equal 0, events.length
|
115
|
+
assert_requested :post, d.instance.api_url,
|
116
|
+
headers: {'Content-Type' => 'application/json'}, body: {
|
117
|
+
'apiKey' => 'INDICATIVE_API_KEY',
|
118
|
+
'events' => [{
|
119
|
+
'eventName' => 'screen_view',
|
120
|
+
'eventUniqueId' => 'a3bd2',
|
121
|
+
'properties' => {
|
122
|
+
'event_name' => 'screen_view',
|
123
|
+
'created_at' => '2015-01-01T10:00:00.000Z',
|
124
|
+
'session_id' => 'a3bd2',
|
125
|
+
'experiments.a' => 1,
|
126
|
+
'experiments.b' => 2
|
127
|
+
},
|
128
|
+
'eventTime' => '2015-01-01T10:00:00+00:00'
|
129
|
+
}]
|
130
|
+
}.to_json, times: 1
|
131
|
+
end
|
80
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-indicative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Millar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -113,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
|
117
|
-
rubygems_version: 2.7.3
|
116
|
+
rubygems_version: 3.0.3
|
118
117
|
signing_key:
|
119
118
|
specification_version: 4
|
120
119
|
summary: Fluentd output plugin to send events to Indicative
|