fluent-plugin-raygun 0.0.1
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 +7 -0
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +11 -0
- data/Rakefile +9 -0
- data/fluent-plugin-raygun.gemspec +27 -0
- data/gemfiles/fluentd_v0.10.gemfile +7 -0
- data/gemfiles/fluentd_v0.12.gemfile +7 -0
- data/lib/fluent/plugin/out_raygun.rb +91 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_raygun.rb +29 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: edc24bda615d05c224793d1baa813dc422a64a98
|
4
|
+
data.tar.gz: d741af36f438c3049e7f944e9da92889877b9434
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c00437615db8bb7d2622bef193d772f0aff546e316f8ee471e79d4731e2cc1b563ade8e5ebc8c643e5def46159ce251aa3c96907ed499acbb5f199386cc3df15
|
7
|
+
data.tar.gz: 92766065e66a203c195986564b49bf6e889e0d3c702c21c6f80a7360d97af4da2bff034efb405829a75715178a8a5ea10ecf21625a93bf679606a8b247dd6445
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 John-Daniel Trask
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## Overview
|
2
|
+
|
3
|
+
fluent-plugin-raygun is a fluentd output plugin that sends aggregated errors/exception events to Raygun. Raygun is a event logging and aggregation platform (and more!).<br>
|
4
|
+
|
5
|
+
## Copyright
|
6
|
+
|
7
|
+
Copyright © 2018 - John-Daniel Trask ([@traskjd](https://twitter.com/traskjd))
|
8
|
+
|
9
|
+
## License
|
10
|
+
|
11
|
+
MIT License
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
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-raygun"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Taylor Lodge"]
|
9
|
+
spec.email = ["taylor@raygun.io"]
|
10
|
+
spec.summary = %q{Fluentd output plugin that sends aggregated errors/exception events to Raygun. Raygun is a error logging and aggregation platform.}
|
11
|
+
spec.homepage = "https://github.com/mindscapehq/fluent-plugin-raygun"
|
12
|
+
spec.license = "Apache-2.0"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "webmock"
|
22
|
+
spec.add_development_dependency "test-unit", ">= 3.1.0"
|
23
|
+
spec.add_development_dependency "appraisal"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "fluentd"
|
26
|
+
spec.add_runtime_dependency "net-http-persistent", "~> 3"
|
27
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
class Fluent::RaygunOutput < Fluent::BufferedOutput
|
2
|
+
Fluent::Plugin.register_output('raygun', self)
|
3
|
+
|
4
|
+
include Fluent::HandleTagNameMixin
|
5
|
+
|
6
|
+
LOG_LEVEL = %w(fatal error warning info debug)
|
7
|
+
EVENT_KEYS = %w(message timestamp time_spent level logger culprit server_name release tags)
|
8
|
+
DEFAULT_HOSTNAME_COMMAND = 'hostname'
|
9
|
+
|
10
|
+
config_param :default_level, :string, :default => 'error'
|
11
|
+
config_param :default_logger, :string, :default => 'fluentd'
|
12
|
+
config_param :endpoint_url, :string, :default => 'https://api.raygun.com'
|
13
|
+
config_param :api_key, :string
|
14
|
+
config_param :flush_interval, :time, :default => 0
|
15
|
+
config_param :hostname_command, :string, :default => 'hostname'
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
require 'time'
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure(conf)
|
24
|
+
super
|
25
|
+
|
26
|
+
if @endpoint_url.nil?
|
27
|
+
raise Fluent::ConfigError, "Raygun: missing parameter for 'endpoint_url'"
|
28
|
+
end
|
29
|
+
|
30
|
+
unless LOG_LEVEL.include?(@default_level)
|
31
|
+
raise Fluent::ConfigError, "Raygun: unsupported default reporting log level for 'default_level'"
|
32
|
+
end
|
33
|
+
|
34
|
+
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
|
35
|
+
@hostname = `#{hostname_command}`.chomp
|
36
|
+
end
|
37
|
+
|
38
|
+
def start
|
39
|
+
super
|
40
|
+
|
41
|
+
require 'net/http/persistent'
|
42
|
+
require 'uri'
|
43
|
+
|
44
|
+
@uri = URI @endpoint_url
|
45
|
+
@http = Net::HTTP::Persistent.new
|
46
|
+
@http.headers['Content-Type'] = 'text/json'
|
47
|
+
@http.headers['X-ApiKey'] = @api_key
|
48
|
+
@http.idle_timeout = 10
|
49
|
+
@http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1]
|
50
|
+
|
51
|
+
log.debug "Started Raygun fluent shipper.."
|
52
|
+
end
|
53
|
+
|
54
|
+
def format(tag, time, record)
|
55
|
+
[tag, time, record].to_msgpack
|
56
|
+
end
|
57
|
+
|
58
|
+
def shutdown
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def write(chunk)
|
63
|
+
chunk.msgpack_each do |tag, time, record|
|
64
|
+
begin
|
65
|
+
notify_raygun(tag, time, record)
|
66
|
+
rescue => e
|
67
|
+
$log.error("Raygun Error:", :error_class => e.class, :error => e.message)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def notify_raygun(tag, time, record)
|
73
|
+
payload = {
|
74
|
+
occurredOn: Time.at(time).utc.iso8601,
|
75
|
+
details: {
|
76
|
+
machineName: @hostname,
|
77
|
+
error: {
|
78
|
+
message: record['messages']
|
79
|
+
},
|
80
|
+
tags: [tag],
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
post = Net::HTTP::Post.new(
|
85
|
+
"#{@endpoint_url}/entries?apikey=#{URI::encode(@api_key)}",
|
86
|
+
)
|
87
|
+
post.body = JSON.generate(payload)
|
88
|
+
|
89
|
+
response = @http.request(@uri, post)
|
90
|
+
end
|
91
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
# pass
|
20
|
+
end
|
21
|
+
}
|
22
|
+
$log = nulllogger
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fluent/plugin/out_raygun'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'webmock/test_unit'
|
3
|
+
require 'yajl'
|
4
|
+
|
5
|
+
WebMock.disable_net_connect!
|
6
|
+
|
7
|
+
class RaygunOutputTest < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
Fluent::Test.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
type raygun
|
14
|
+
endpoint_url https://api.raygun.com
|
15
|
+
api_key abc123
|
16
|
+
hostname_command hostname -s
|
17
|
+
remove_tag_prefix input.
|
18
|
+
]
|
19
|
+
|
20
|
+
def create_driver(conf=CONFIG,tag='test',use_v1=false)
|
21
|
+
require 'fluent/version'
|
22
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new('0.12')
|
23
|
+
Fluent::Test::OutputTestDriver.new(Fluent::RaygunOutput, tag).configure(conf, use_v1)
|
24
|
+
else
|
25
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::RaygunOutput, tag).configure(conf, use_v1)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-raygun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Taylor Lodge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
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: rake
|
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: webmock
|
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: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
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.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: appraisal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fluentd
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: net-http-persistent
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- taylor@raygun.io
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- fluent-plugin-raygun.gemspec
|
124
|
+
- gemfiles/fluentd_v0.10.gemfile
|
125
|
+
- gemfiles/fluentd_v0.12.gemfile
|
126
|
+
- lib/fluent/plugin/out_raygun.rb
|
127
|
+
- test/helper.rb
|
128
|
+
- test/plugin/test_out_raygun.rb
|
129
|
+
homepage: https://github.com/mindscapehq/fluent-plugin-raygun
|
130
|
+
licenses:
|
131
|
+
- Apache-2.0
|
132
|
+
metadata: {}
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
requirements: []
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 2.5.1
|
150
|
+
signing_key:
|
151
|
+
specification_version: 4
|
152
|
+
summary: Fluentd output plugin that sends aggregated errors/exception events to Raygun.
|
153
|
+
Raygun is a error logging and aggregation platform.
|
154
|
+
test_files:
|
155
|
+
- test/helper.rb
|
156
|
+
- test/plugin/test_out_raygun.rb
|