fluent-plugin-snowplow 0.1.1 → 0.1.2
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/lib/fluent/plugin/out_snowplow.rb +56 -0
 - data/lib/fluent/plugin/snowplow/version.rb +1 -1
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8ac4e04cdbc1a1575ecb5bbb3519e49158071162
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 832790a8ce83af161570561d51d63e9fa611cfde
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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
         
     | 
    
        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. 
     | 
| 
      
 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
         
     |