fluent-plugin-indicative 0.1.7 → 0.1.8
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 +2 -2
- data/lib/fluent/plugin/out_indicative.rb +2 -3
- data/test/plugin/test_out_indicative.rb +38 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5156275d2e768b5d94cfb54dacac2edbd1730480dd13b94f02df6b3fb2345fd6
|
4
|
+
data.tar.gz: 8014b67c109af46ddbb9a9085cb8da4c93bc23f82a1c926418074a2832c36f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf214eec01b00c32e7928d2c040bc9c0e44b03c4f5fac422e363ca4bed3aaafa2f211e426ba598f63c4d41b8d1edaffa38fa579817d9ecfc27361883220edaa8
|
7
|
+
data.tar.gz: c7c971b0fac7a26fffd47402f1915d8bbdfe79f78da32513f1207ec29e53b6abbde6319027c99873ede53a4c7e15927cbc5964c567eb3024f6472796af9fa74a
|
@@ -3,10 +3,10 @@ $:.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.8"
|
7
7
|
s.authors = ["Sam Millar"]
|
8
8
|
s.email = ["sam@millar.io"]
|
9
|
-
s.homepage = "https://github.com/
|
9
|
+
s.homepage = "https://github.com/mixcloud/fluent-plugin-indicative"
|
10
10
|
s.summary = %q{Fluentd output plugin to send events to Indicative}
|
11
11
|
|
12
12
|
s.files = `git ls-files`.split("\n")
|
@@ -17,8 +17,6 @@ def flatten_hash(hash)
|
|
17
17
|
v.each do |item|
|
18
18
|
if item.is_a?(Hash) && item.has_key?("key") && item.has_key?("value")
|
19
19
|
h["#{k}.#{item["key"]}"] = item["value"]
|
20
|
-
else
|
21
|
-
h["#{k}.#{item}"] = true
|
22
20
|
end
|
23
21
|
end
|
24
22
|
else
|
@@ -37,6 +35,7 @@ class Fluent::Plugin::IndicativeOutput < Fluent::Plugin::Output
|
|
37
35
|
config_param :event_name_key, :string
|
38
36
|
config_param :event_time_key, :string
|
39
37
|
config_param :event_unique_id_keys, :array, value_type: :string
|
38
|
+
config_param :event_filter_key, :string, default: nil
|
40
39
|
|
41
40
|
def process(tag, es)
|
42
41
|
es.each_slice(@batch_size) do |events|
|
@@ -61,7 +60,7 @@ class Fluent::Plugin::IndicativeOutput < Fluent::Plugin::Output
|
|
61
60
|
|
62
61
|
payload = {
|
63
62
|
apiKey: @api_key,
|
64
|
-
events: events.map do |data|
|
63
|
+
events: events.filter {|data| !@event_filter_key or data[@event_filter_key] != false}.map do |data|
|
65
64
|
unique_id_key = @event_unique_id_keys.find {|k| data[k]}
|
66
65
|
{
|
67
66
|
eventName: data[@event_name_key],
|
@@ -12,6 +12,14 @@ class IndicativeOutputTest < Test::Unit::TestCase
|
|
12
12
|
event_unique_id_keys user_id, session_id
|
13
13
|
]
|
14
14
|
|
15
|
+
FILTER_CONFIG = %[
|
16
|
+
api_key INDICATIVE_API_KEY
|
17
|
+
event_name_key event_name
|
18
|
+
event_time_key created_at
|
19
|
+
event_unique_id_keys user_id, session_id
|
20
|
+
event_filter_key indicative
|
21
|
+
]
|
22
|
+
|
15
23
|
BUFFER_CONFIG = %[
|
16
24
|
api_key INDICATIVE_API_KEY
|
17
25
|
event_name_key event_name
|
@@ -65,24 +73,13 @@ class IndicativeOutputTest < Test::Unit::TestCase
|
|
65
73
|
}.to_json, times: 1
|
66
74
|
end
|
67
75
|
|
68
|
-
def
|
69
|
-
d = create_driver(
|
70
|
-
stub_request(:any, d.instance.api_url)
|
71
|
-
d.run(default_tag: 'test') do
|
72
|
-
5.times do
|
73
|
-
d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'user_id' => nil, 'screen' => {'id' => 'index'}})
|
74
|
-
end
|
75
|
-
end
|
76
|
-
events = d.events
|
77
|
-
assert_equal 0, events.length
|
78
|
-
assert_requested :post, d.instance.api_url, times: 1
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_array_transformation
|
82
|
-
d = create_driver(STREAM_CONFIG)
|
76
|
+
def test_emit_stream_with_filter
|
77
|
+
d = create_driver(FILTER_CONFIG)
|
83
78
|
stub_request(:any, d.instance.api_url)
|
84
79
|
d.run(default_tag: 'test') do
|
85
|
-
d.feed({'event_name' => '
|
80
|
+
d.feed({'event_name' => 'filter_nil', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2'})
|
81
|
+
d.feed({'event_name' => 'filter_false', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'indicative' => false})
|
82
|
+
d.feed({'event_name' => 'filter_true', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'indicative' => true})
|
86
83
|
end
|
87
84
|
events = d.events
|
88
85
|
assert_equal 0, events.length
|
@@ -90,20 +87,41 @@ class IndicativeOutputTest < Test::Unit::TestCase
|
|
90
87
|
headers: {'Content-Type' => 'application/json'}, body: {
|
91
88
|
'apiKey' => 'INDICATIVE_API_KEY',
|
92
89
|
'events' => [{
|
93
|
-
'eventName' => '
|
90
|
+
'eventName' => 'filter_nil',
|
94
91
|
'eventUniqueId' => 'a3bd2',
|
95
92
|
'properties' => {
|
96
|
-
'event_name' => '
|
93
|
+
'event_name' => 'filter_nil',
|
94
|
+
'created_at' => '2015-01-01T10:00:00.000Z',
|
95
|
+
'session_id' => 'a3bd2'
|
96
|
+
},
|
97
|
+
'eventTime' => '2015-01-01T10:00:00+00:00'
|
98
|
+
}, {
|
99
|
+
'eventName' => 'filter_true',
|
100
|
+
'eventUniqueId' => 'a3bd2',
|
101
|
+
'properties' => {
|
102
|
+
'event_name' => 'filter_true',
|
97
103
|
'created_at' => '2015-01-01T10:00:00.000Z',
|
98
104
|
'session_id' => 'a3bd2',
|
99
|
-
'
|
100
|
-
'experiments.c' => true
|
105
|
+
'indicative' => true
|
101
106
|
},
|
102
107
|
'eventTime' => '2015-01-01T10:00:00+00:00'
|
103
108
|
}]
|
104
109
|
}.to_json, times: 1
|
105
110
|
end
|
106
111
|
|
112
|
+
def test_emit_buffer
|
113
|
+
d = create_driver(BUFFER_CONFIG)
|
114
|
+
stub_request(:any, d.instance.api_url)
|
115
|
+
d.run(default_tag: 'test') do
|
116
|
+
5.times do
|
117
|
+
d.feed({'event_name' => 'screen_view', 'created_at' => '2015-01-01T10:00:00.000Z', 'session_id' => 'a3bd2', 'user_id' => nil, 'screen' => {'id' => 'index'}})
|
118
|
+
end
|
119
|
+
end
|
120
|
+
events = d.events
|
121
|
+
assert_equal 0, events.length
|
122
|
+
assert_requested :post, d.instance.api_url, times: 1
|
123
|
+
end
|
124
|
+
|
107
125
|
def test_key_value_object_transformation
|
108
126
|
d = create_driver(STREAM_CONFIG)
|
109
127
|
stub_request(:any, d.instance.api_url)
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Millar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -95,7 +95,7 @@ files:
|
|
95
95
|
- lib/fluent/plugin/out_indicative.rb
|
96
96
|
- test/helper.rb
|
97
97
|
- test/plugin/test_out_indicative.rb
|
98
|
-
homepage: https://github.com/
|
98
|
+
homepage: https://github.com/mixcloud/fluent-plugin-indicative
|
99
99
|
licenses: []
|
100
100
|
metadata: {}
|
101
101
|
post_install_message:
|