fluent-plugin-rabbitmq-json-trace-parser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49021a0a8d8498676c1047170fa25e8782f6f21f
4
+ data.tar.gz: 7799f97c45e4bc94ccfd60d12c991fd77d78be10
5
+ SHA512:
6
+ metadata.gz: c346f82b107602a5eefde06a5fff103aece51b57aa6c92f1bc8d92939070862d8822286390a3e96b35cecbbaf4c919da2ac6785bf9d6d280ff9afecc1a4fd53e
7
+ data.tar.gz: c1ba4c1e0d1fb23ce7c7ba05433a889ea0221c9846ea9f0feb61e5217fc4816eb84dfd67350ea0c06c40f43694fa0315c75d78a671d0feef0d95fff4e666dbb0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.7
7
+ - 2.2.3
8
+ - ruby-head
9
+
10
+ os:
11
+ - linux
12
+ - osx
13
+
14
+ sudo: false
15
+
16
+ branches:
17
+ only:
18
+ - master
19
+
20
+ matrix:
21
+ allow_failures:
22
+ - rvm: ruby-head
23
+
24
+ before_install: gem install bundler -v 1.10.6
25
+
26
+ script: bundle exec rake
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Max Riveiro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Fluent::Plugin::RabbitMQJSONTraceParser::Parser
2
+
3
+ [![Build Status](https://travis-ci.org/kavu/fluent-plugin-rabbitmq-json-trace-parser.svg?branch=master)](https://travis-ci.org/kavu/fluent-plugin-rabbitmq-json-trace-parser)
4
+
5
+ Fluentd Parser plugin for RabbitMQ Trace log in JSON format.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'fluent-plugin-rabbitmq-json-trace-parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem fluent-plugin-rabbitmq-json-trace-parser
22
+
23
+ ## Configuration
24
+
25
+ ```
26
+ <source>
27
+ @type tail
28
+ path /path/to/log
29
+
30
+ tag rabbitmq.trace
31
+
32
+ format rabbitmq_json_trace
33
+ payload_type 'json'
34
+ </source>
35
+ ```
36
+
37
+ You can use two values for `payload_type`:
38
+ 1. `base64` (default) — to decode payload from Base64 to something meaningful
39
+ 1. `json` — to decode payload from Base64 and then treat it like a JSON object
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
48
+
49
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'lib'
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'fluent-plugin-rabbitmq-json-trace-parser'
7
+ spec.version = '0.1.0'
8
+ spec.authors = ['Max Riveiro']
9
+ spec.email = %w(kavu13@gmail.com)
10
+
11
+ spec.summary = 'Fluentd Parser plugin for RabbitMQ Trace log in JSON format.'
12
+ spec.description = 'Fluentd Parser plugin for RabbitMQ Trace log in JSON format.'
13
+ spec.homepage = 'https://github.com/kavu/fluent-plugin-rabbitmq-json-trace-parser'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
17
+ spec.require_paths = %w(lib)
18
+
19
+ spec.required_ruby_version = '>= 1.9.3'
20
+
21
+ spec.add_runtime_dependency 'fluentd', '>= 0.10.58'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'test-unit', '~> 3.1.4'
26
+ end
@@ -0,0 +1,57 @@
1
+ require 'base64'
2
+
3
+ module Fluent
4
+ class TextParser
5
+ class RabbitMQJSONTraceParser < JSONParser
6
+ Plugin.register_parser('rabbitmq_json_trace', self)
7
+
8
+ config_param :time_key, :string, :default => 'timestamp'
9
+ config_param :time_format, :string, :default => '%Y-%m-%d %H:%M:%S:%L'
10
+ config_param :payload_type, :enum, :default => :base64, :list => [:json, :base64]
11
+
12
+ def parse(text)
13
+ record = Yajl.load(text)
14
+
15
+ record['payload'] = ::Base64.decode64(record['payload'])
16
+
17
+ if @payload_type == :json
18
+ record['payload'] = Yajl.load(record['payload'])
19
+ end
20
+
21
+ time = get_time(record)
22
+
23
+ if block_given?
24
+ yield time, record
25
+ else
26
+ return time, record
27
+ end
28
+ rescue Yajl::ParseError
29
+ if block_given?
30
+ yield nil, nil
31
+ else
32
+ return nil, nil
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def get_time(record)
39
+ value = @keep_time_key ? record[@time_key] : record.delete(@time_key)
40
+
41
+ if value
42
+ if @time_format
43
+ @mutex.synchronize { @time_parser.parse(value) }
44
+ else
45
+ begin
46
+ value.to_i
47
+ rescue => e
48
+ raise ParserError, "invalid time value: value = #{value}, error_class = #{e.class.name}, error = #{e.message}"
49
+ end
50
+ end
51
+ elsif @estimate_current_event
52
+ Engine.now
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-rabbitmq-json-trace-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Max Riveiro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.58
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.58
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.4
69
+ description: Fluentd Parser plugin for RabbitMQ Trace log in JSON format.
70
+ email:
71
+ - kavu13@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - fluent-plugin-rabbitmq-json-trace-parser.gemspec
84
+ - lib/fluent/plugin/parser_rabbitmq_json_trace.rb
85
+ homepage: https://github.com/kavu/fluent-plugin-rabbitmq-json-trace-parser
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: 1.9.3
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.14
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Fluentd Parser plugin for RabbitMQ Trace log in JSON format.
109
+ test_files: []
110
+ has_rdoc: