fluent-plugin-snowplow 0.1.1 → 0.1.2

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: ff0db0fa4ef9c6a8421448aca46c32963cff1d26
4
- data.tar.gz: 06c318670a4c1773e7a19929924b34d6ec6e830e
3
+ metadata.gz: 8ac4e04cdbc1a1575ecb5bbb3519e49158071162
4
+ data.tar.gz: 832790a8ce83af161570561d51d63e9fa611cfde
5
5
  SHA512:
6
- metadata.gz: 2f91a7d2ad2c4d8908307bddb4ee1d0b74da11946df9134f5e66ec5b2ad1175427768b02a1cae8d4be900d4a0edf68ed25ee425453749286025101987a7da692
7
- data.tar.gz: b8c9fb3529778b3d5560a2f0bcbb86e6a9e104a2745296e29498fe532c9f56601e3d6df51ae8704e9f59b0e028a2430201d7ed25123984a801c1e3d3f6b08852
6
+ metadata.gz: 68a13d0ce72c8d8db784cf57a42938e5101dee9f14ab6abeda4fc89432777a4c16afd08715301db38db02acb3292f513a8da1107794bb7cf69e6f3b0ca65d726
7
+ data.tar.gz: 5701f5cb61b74ed1f4c6a3c301a20ac18541afb3e2d1437618c64d5d94c3f4ef71770b7cc7f875052820e7f8569a096e917028103d37f725d213255bfe2e8943
@@ -0,0 +1,56 @@
1
+ require 'snowplow-tracker'
2
+
3
+ class Fluent::SomeOutput < Fluent::TimeSlicedOutput
4
+ Fluent::Plugin.register_output('snowplow', self)
5
+
6
+ config_param :host, :string
7
+ config_param :buffer_size, :integer
8
+ config_param :protocol, :string
9
+ config_param :method, :string
10
+
11
+ def configure(conf)
12
+ super
13
+ end
14
+
15
+ def start
16
+ super
17
+
18
+ @emitter = SnowplowTracker::Emitter.new(@host, {
19
+ buffer_size: @buffer_size,
20
+ protocol: @protocol,
21
+ method: @method
22
+ })
23
+
24
+ @trackers = {}
25
+ end
26
+
27
+ def stop
28
+ @tracker.flush
29
+ end
30
+
31
+ def format(tag, time, record)
32
+ [tag, time, record].to_msgpack
33
+ end
34
+
35
+ def tracker_for(application)
36
+ @trackers[application] ||= SnowplowTracker::Tracker.new(@emitter, nil, nil, application)
37
+ @trackers[application]
38
+ end
39
+
40
+ def write(chunk)
41
+ application, tracker = nil, nil
42
+
43
+ chunk.msgpack_each do |_, _, record|
44
+ schema = record['schema']
45
+ message = JSON.parse record['message']
46
+ true_timestamp = record['true_timestamp']
47
+ application = record['application']
48
+ tracker = tracker_for(application)
49
+
50
+ self_describing_json = SnowplowTracker::SelfDescribingJson.new(schema, message)
51
+ tracker.track_self_describing_event(self_describing_json, nil, SnowplowTracker::TrueTimestamp.new(true_timestamp.to_i))
52
+ end
53
+
54
+ tracker.flush
55
+ end
56
+ end
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module Snowplow
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-snowplow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Souza
@@ -70,6 +70,7 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - fluent-plugin-snowplow.gemspec
73
+ - lib/fluent/plugin/out_snowplow.rb
73
74
  - lib/fluent/plugin/snowplow.rb
74
75
  - lib/fluent/plugin/snowplow/version.rb
75
76
  homepage: http://www.getninjas.com.br