fluent-plugin-airbrake-logger 0.0.1

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: cb809b82dafc2b27098afa1e382d7134eaea8436
4
+ data.tar.gz: 58398db409858f2a972d848b9d565155bc1f03d3
5
+ SHA512:
6
+ metadata.gz: 7188a44e25bec746760196ac63c5bc55092b0797b0fc5549e31ef5c108f3e2bdf4f73eed5304f7908de1e5d8c8b01dbd1ab2c97eb64c09dbdff418eb874a7110
7
+ data.tar.gz: 77c22ecf84d224175f1cb30806e9b26c538b91c7c033026f17982b0e7b4edefcc678f4efb89972591b5a5feb2329f81ffa0d7aaccee2e86e5d7981dabb34a1b9
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.yardoc
2
+ Gemfile.lock
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
10
+ .bundle
11
+ pkg/*
12
+ *.tmproj
13
+ tmtags
14
+ *~
15
+ \#*
16
+ .\#*
17
+ *.swp
18
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-airbrake-logger.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Shuichi Ohsawa
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,41 @@
1
+ # Fluent::Plugin::Airbrake::Logger
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fluent/plugin/airbrake/logger`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'fluent-plugin-airbrake-logger'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install fluent-plugin-airbrake-logger
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fluent-plugin-airbrake-logger.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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-airbrake-logger"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Shuichi Ohsawa"]
9
+ spec.email = ["ohsawa0515@gmail.com"]
10
+
11
+ spec.summary = %q{Output filter plugin to Airbrake(Errbit) by fluent-logger-ruby}
12
+ spec.description = %q{Output filter plugin to Airbrake(Errbit) by fluent-logger-ruby}
13
+ spec.homepage = "https://github.com/ohsawa0515/fluent-plugin-airbrake-logger"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "fluentd"
24
+ spec.add_runtime_dependency "fluentd"
25
+ spec.add_runtime_dependency "airbrake", ">= 4.3.0"
26
+ end
@@ -0,0 +1,120 @@
1
+ class Fluent::ErrbitGeesOutput < Fluent::Output
2
+ Fluent::Plugin.register_output('airbrake_logger', self)
3
+
4
+ LOGLEVEL_MAP = {
5
+ 'CRITICAL' => 50,
6
+ 'FATAL' => 50,
7
+ 'ERROR' => 40,
8
+ 'WARNING' => 30,
9
+ 'WARN' => 30,
10
+ 'INFO' => 20,
11
+ 'DEBUG' => 10,
12
+ }
13
+
14
+ config_param :api_key, :string, :default => nil
15
+ config_param :host, :string, :default => 'localhost'
16
+ config_param :port, :integer, :default => '80'
17
+ # +true+ for https connections, +false+ for http connections.
18
+ config_param :secure, :bool, :default => true
19
+ # +true+ to use whatever CAs OpenSSL has installed on your system. +false+ to use the ca-bundle.crt file included in Airbrake itself (reccomended and default)
20
+ config_param :use_system_ssl_cert_chain, :bool, :default => true
21
+ # The HTTP open timeout in seconds (defaults to 2).
22
+ config_param :http_open_timeout, :integer, :default => nil
23
+ # The HTTP read timeout in seconds (defaults to 5).
24
+ config_param :http_read_timeout, :integer, :default => nil
25
+ config_param :proxy_host, :string, :default => nil
26
+ config_param :proxy_port, :integer, :default => nil
27
+ config_param :proxy_user, :string, :default => nil
28
+ config_param :proxy_pass, :string, :default => nil
29
+ # defaults to ["password", "password_confirmation"]
30
+ config_param :param_filters, :string, :default => nil
31
+ config_param :development_environments, :string, :default => nil
32
+ config_param :development_lookup, :bool, :default => false
33
+ config_param :environment_name, :string, :default => 'production'
34
+ config_param :project_root, :string, :default => ''
35
+ config_param :notifier_name, :string, :default => nil
36
+ config_param :notifier_version, :string, :default => nil
37
+ config_param :notifier_url, :string, :default => nil
38
+ config_param :user_information, :string, :default => nil
39
+ config_param :user_attributes, :string, :default => nil
40
+ config_param :framework, :string, :default => nil
41
+ config_param :project_id, :string, :default => nil
42
+ config_param :loglevel, :string, :default => 'DEBUG'
43
+ config_param :log_path, :string, :default => nil
44
+
45
+ def initialize
46
+ super
47
+ require 'airbrake'
48
+ end
49
+
50
+ def configure(conf)
51
+ super
52
+
53
+ Airbrake.configure do |config|
54
+ config.api_key = @api_key
55
+ config.host = @host
56
+ config.port = @port ? @port: (@secure ? 443: 80)
57
+ config.secure = @secure
58
+ config.use_system_ssl_cert_chain = @use_system_ssl_cert_chain
59
+ config.http_open_timeout = @http_open_timeout if @http_open_timeout
60
+ config.http_read_timeout = @http_read_timeout if @http_read_timeout
61
+ config.proxy_host = @proxy_host
62
+ config.proxy_port = @proxy_port
63
+ config.proxy_user = @proxy_user
64
+ config.proxy_pass = @proxy_pass
65
+ config.param_filters = @param_filters.split(/\s+/) if @param_filters
66
+ config.development_environments = @development_environments.split(/\s+/) if @development_environments
67
+ config.development_lookup = @development_lookup
68
+ config.environment_name = @environment_name
69
+ config.project_root = @project_root
70
+ config.notifier_name = @notifier_name if @notifier_name
71
+ config.notifier_version = @notifier_version if @notifier_version
72
+ config.notifier_url = @notifier_url if @notifier_url
73
+ config.user_information = @user_information if @user_information
74
+ config.user_attribute = @user_attribute.split(/s+/) if @user_attribute
75
+ config.framework = @framework if @framework
76
+ config.project_id = @project_id
77
+ config.logger = Logger.new(@log_path) if @log_path
78
+ @aconf = config
79
+ end
80
+
81
+ @sender = Airbrake::Sender.new(@aconf)
82
+ @loglevel = LOGLEVEL_MAP[@loglevel.upcase]
83
+ end
84
+
85
+ def notification_needed(tag, time, record)
86
+ severity_map = LOGLEVEL_MAP[record['severity']]
87
+ record['severity'] ? severity_map >= @loglevel: false
88
+ end
89
+
90
+ def build_error_message(record)
91
+ error_message = record['error_message'] ? record['error_message'] : 'Notification'
92
+ return "[#{record['severity']}] #{error_message}"
93
+ end
94
+
95
+ def build_error_backtrace(record)
96
+ return record['error_backtrace'] ? record['error_backtrace'] : record['backtrace']
97
+ end
98
+
99
+ def emit(tag, es, chain)
100
+ es.each do |time, record|
101
+
102
+ next unless notification_needed(tag, time, record)
103
+
104
+ other_record = record.reject{|k,v| %w(error_class error_backtrace error_message application_name service_name).include?(k)}
105
+ @notice = Airbrake::Notice.new(@aconf.merge(
106
+ :error_class => record['error_class'],
107
+ :backtrace => build_error_backtrace(record),
108
+ :error_message => build_error_message(record),
109
+ :hostname => record['hostname'],
110
+ :component => record['application_name'],
111
+ :action => record['service_name'],
112
+ :cgi_data => other_record,
113
+ ))
114
+
115
+ @sender.send_to_airbrake(@notice) if @notice
116
+ end
117
+ chain.next
118
+ end
119
+ end
120
+
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-airbrake-logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shuichi Ohsawa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fluentd
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: airbrake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: 4.3.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 4.3.0
83
+ description: Output filter plugin to Airbrake(Errbit) by fluent-logger-ruby
84
+ email:
85
+ - ohsawa0515@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - fluent-plugin-airbrake-logger.gemspec
96
+ - lib/fluent/plugin/out_airbrake_logger.rb
97
+ homepage: https://github.com/ohsawa0515/fluent-plugin-airbrake-logger
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.0.14
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Output filter plugin to Airbrake(Errbit) by fluent-logger-ruby
121
+ test_files: []