fluent-plugin-sentry-rubrik 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +29 -0
- data/Appraisals +8 -0
- data/Gemfile +4 -0
- data/LICENSE +14 -0
- data/README.md +126 -0
- data/Rakefile +9 -0
- data/fluent-plugin-sentry.gemspec +32 -0
- data/gemfiles/fluentd_v0.10.gemfile +7 -0
- data/gemfiles/fluentd_v0.12.gemfile +7 -0
- data/lib/fluent/plugin/out_sentry.rb +114 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_sentry.rb +129 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3507f5f5fab7e7d0bf4f63a068a477e5104ccb4c
|
4
|
+
data.tar.gz: 8e1421ef2d9a2aec57bbbda7e352d303edc1d660
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61ce7bb5232e41a126d88994200950152cecc063739612188847ddace037280a2d0fc42af1440b2fade579bd950167948966bdb9ae9dec94f4feba9556432a8c
|
7
|
+
data.tar.gz: 185c04a69f1f765168a529d3aa017f6280a5af9117c76cba59eff1a2224e6ff8bc27f740a29f7e43fc6359e7ce49e9e64e75289c63fe49f7d38de91e6fb46501
|
data/.travis.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.2
|
5
|
+
- 2.1
|
6
|
+
|
7
|
+
before_script:
|
8
|
+
- export RAILS_ENV=default
|
9
|
+
|
10
|
+
gemfile:
|
11
|
+
- Gemfile
|
12
|
+
- gemfiles/fluentd_v0.10.gemfile
|
13
|
+
- gemfiles/fluentd_v0.12.gemfile
|
14
|
+
|
15
|
+
# to avoid travis-ci issue since 2015-12-25
|
16
|
+
before_install:
|
17
|
+
- gem update bundler
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
include:
|
21
|
+
- rvm: 1.9.3
|
22
|
+
gemfile: gemfiles/fluentd_v0.10.gemfile
|
23
|
+
- rvm: 1.9.3
|
24
|
+
gemfile: gemfiles/fluentd_v0.12.gemfile
|
25
|
+
- rvm: 2.0.0
|
26
|
+
gemfile: gemfiles/fluentd_v0.10.gemfile
|
27
|
+
- rvm: 2.0.0
|
28
|
+
gemfile: gemfiles/fluentd_v0.12.gemfile
|
29
|
+
|
data/Appraisals
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2014- Kentaro Yoshida
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
# fluent-plugin-sentry [![Build Status](https://travis-ci.org/y-ken/fluent-plugin-sentry.png?branch=master)](https://travis-ci.org/y-ken/fluent-plugin-sentry)
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
fluent-plugin-sentry is a fluentd output plugin that sends aggregated errors/exception events to Sentry. Sentry is a event logging and aggregation platform.<br>
|
6
|
+
|
7
|
+
Sentry alone does not buffer incoming requests, so if your Sentry instance is under load, Sentry can respond with a 503 Service Unavailable.<br>
|
8
|
+
|
9
|
+
fluent-plugin-sentry extends fluent buffered output and enables a fluend user to buffer and flush messages to Sentry with reliable delivery.
|
10
|
+
|
11
|
+
* [Sentry Official web](https://getsentry.com/welcome/)
|
12
|
+
* [Sentry Documents](http://sentry.readthedocs.org/en/latest/) [Screenshots](https://github.com/getsentry/sentry#screenshots)
|
13
|
+
|
14
|
+
> ![http://blog.getsentry.com/images/hero.png](https://cloud.githubusercontent.com/assets/1734549/5498750/2b471a6c-8767-11e4-8634-961c99e635ed.png)
|
15
|
+
(quoted from http://blog.getsentry.com/)
|
16
|
+
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
install with `gem` or td-agent provided command as:
|
21
|
+
|
22
|
+
```bash
|
23
|
+
# for fluentd
|
24
|
+
$ gem install fluent-plugin-sentry
|
25
|
+
|
26
|
+
# for td-agent
|
27
|
+
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-sentry
|
28
|
+
|
29
|
+
# for td-agent2
|
30
|
+
$ sudo td-agent-gem install fluent-plugin-sentry
|
31
|
+
```
|
32
|
+
|
33
|
+
## Preparation
|
34
|
+
|
35
|
+
create sentry dashboard first. It could start with cost free!!
|
36
|
+
|
37
|
+
* Create an account at https://getsentry.com/pricing/
|
38
|
+
|
39
|
+
OR
|
40
|
+
|
41
|
+
* Launch Sentry at the self manager server with https://github.com/getsentry/sentry
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
```xml
|
46
|
+
<source>
|
47
|
+
@type forward
|
48
|
+
</source>
|
49
|
+
|
50
|
+
<match notify.**>
|
51
|
+
@type sentry
|
52
|
+
|
53
|
+
# Set endpoint API URL
|
54
|
+
endpoint_url https://API_KEY:API_PASSWORD@app.getsentry.com/PROJECT_ID
|
55
|
+
|
56
|
+
# Set default events value of 'server_name'
|
57
|
+
# To set short hostname, set like below.
|
58
|
+
hostname_command hostname -s
|
59
|
+
|
60
|
+
# rewrite shown tag name for Sentry dashboard
|
61
|
+
remove_tag_prefix notify.
|
62
|
+
</match>
|
63
|
+
```
|
64
|
+
|
65
|
+
## Parameters
|
66
|
+
|
67
|
+
* endpoint_url (Required)<br>
|
68
|
+
Set to the sentry DSN, as found in the Sentry dashboard.
|
69
|
+
|
70
|
+
* default_level<br>
|
71
|
+
[default] info
|
72
|
+
|
73
|
+
If a `level` is not present in the log, `default_level` is assumed.
|
74
|
+
|
75
|
+
* default_logger<br>
|
76
|
+
[default] fluentd
|
77
|
+
|
78
|
+
If a `logger` is not present in the log, `default_logger` is assumed.
|
79
|
+
|
80
|
+
* hostname_command<br>
|
81
|
+
[default] hostname
|
82
|
+
The name of the server reporting the error.
|
83
|
+
|
84
|
+
* flush_interval<br>
|
85
|
+
[default] 0sec
|
86
|
+
|
87
|
+
* report_levels
|
88
|
+
[default] fatal error warning
|
89
|
+
|
90
|
+
Only report to Sentry logs with `report_levels`.
|
91
|
+
|
92
|
+
Note that the default ignores `info` and `debug` logs. And `default_level`
|
93
|
+
defaults to `info`. This might ignore more logs than you anticipated.
|
94
|
+
|
95
|
+
* tags_key
|
96
|
+
[default] ""
|
97
|
+
|
98
|
+
Report those items with the given key as tags to Sentry. This makes it possible
|
99
|
+
to correlate events via tags. Access to structured tag is supported, for
|
100
|
+
example, given the following log:
|
101
|
+
|
102
|
+
```
|
103
|
+
"{ msg: foo k8s: { app: myapp, container: mycontainer } }
|
104
|
+
```
|
105
|
+
The tag key `k8s.app` will add the tag `k8s.app: myapp` to the Sentry event.
|
106
|
+
|
107
|
+
It also support rewriting Tag with SetTagKeyMixin.
|
108
|
+
|
109
|
+
* remove_tag_prefix
|
110
|
+
* remove_tag_suffix
|
111
|
+
* add_tag_prefix
|
112
|
+
* add_tag_suffix
|
113
|
+
|
114
|
+
## Blog Articles
|
115
|
+
|
116
|
+
## TODO
|
117
|
+
|
118
|
+
Pull requests are very welcome!!
|
119
|
+
|
120
|
+
## Copyright
|
121
|
+
|
122
|
+
Copyright © 2014- Kentaro Yoshida ([@yoshi_ken](https://twitter.com/yoshi_ken))
|
123
|
+
|
124
|
+
## License
|
125
|
+
|
126
|
+
Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
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-sentry-rubrik"
|
7
|
+
spec.version = "0.0.6"
|
8
|
+
spec.authors = ["Kentaro Yoshida", "François-Xavier Bourlet"]
|
9
|
+
spec.email = ["y.ken.studio@gmail.com", "fx.bourlet@rubrik.com"]
|
10
|
+
spec.summary = %q{Fluentd output plugin that sends aggregated errors/exception events to Sentry. Sentry is a event logging and aggregation platform.}
|
11
|
+
spec.homepage = "https://github.com/bombela/fluent-plugin-sentry"
|
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", "~> 1.16"
|
20
|
+
spec.add_development_dependency "rake", "~> 12.3"
|
21
|
+
spec.add_development_dependency "webmock", "~> 3.3"
|
22
|
+
spec.add_development_dependency "test-unit", "~> 3.2"
|
23
|
+
spec.add_development_dependency "appraisal", "~> 2.2"
|
24
|
+
|
25
|
+
# Since Fluentd v0.14 requires ruby 2.1 or later.
|
26
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION < "2.1"
|
27
|
+
spec.add_runtime_dependency "fluentd", "< 0.14"
|
28
|
+
else
|
29
|
+
spec.add_runtime_dependency "fluentd", "~> 1.1"
|
30
|
+
end
|
31
|
+
spec.add_runtime_dependency "sentry-raven", "~> 2.7"
|
32
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'fluent/output'
|
2
|
+
require 'time'
|
3
|
+
require 'raven'
|
4
|
+
|
5
|
+
|
6
|
+
module Fluent
|
7
|
+
class Fluent::SentryOutput < BufferedOutput
|
8
|
+
Fluent::Plugin.register_output('sentry', self)
|
9
|
+
|
10
|
+
include Fluent::HandleTagNameMixin
|
11
|
+
|
12
|
+
LOG_LEVEL = %w(fatal error warning info debug).to_set()
|
13
|
+
EVENT_KEYS = %w(message msg timestamp level logger).to_set()
|
14
|
+
DEFAULT_HOSTNAME_COMMAND = 'hostname'
|
15
|
+
|
16
|
+
config_param :default_level, :string, :default => 'info'
|
17
|
+
config_param :default_logger, :string, :default => 'fluentd'
|
18
|
+
config_param :report_levels, :array, value_type: :string, :default => %w(fatal error warning)
|
19
|
+
config_param :tags_key, :array, value_type: :string, :default => %w()
|
20
|
+
config_param :endpoint_url, :string
|
21
|
+
config_param :flush_interval, :time, :default => 0
|
22
|
+
config_param :hostname_command, :string, :default => 'hostname'
|
23
|
+
|
24
|
+
def configure(conf)
|
25
|
+
super
|
26
|
+
|
27
|
+
if @endpoint_url.nil?
|
28
|
+
raise Fluent::ConfigError, "sentry: missing parameter for 'endpoint_url'"
|
29
|
+
end
|
30
|
+
|
31
|
+
unless LOG_LEVEL.include?(@default_level)
|
32
|
+
raise Fluent::ConfigError, "sentry: unsupported default reporting log level for 'default_level'"
|
33
|
+
end
|
34
|
+
|
35
|
+
@report_levels = @report_levels.to_set()
|
36
|
+
@report_levels.each do |report_level|
|
37
|
+
unless LOG_LEVEL.include?(report_level)
|
38
|
+
raise Fluent::ConfigError, "sentry: unsupported level in report_levels for 'report_level'"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
@tags_key = @tags_key.to_set()
|
43
|
+
|
44
|
+
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
|
45
|
+
@hostname = `#{hostname_command}`.chomp
|
46
|
+
|
47
|
+
@configuration = Raven::Configuration.new
|
48
|
+
@configuration.server = @endpoint_url
|
49
|
+
@configuration.server_name = @hostname
|
50
|
+
@configuration.send_modules = false
|
51
|
+
@configuration.release = nil
|
52
|
+
@client = Raven::Client.new(@configuration)
|
53
|
+
@context = Raven::Context.new
|
54
|
+
end
|
55
|
+
|
56
|
+
def start
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def format(tag, time, record)
|
61
|
+
[tag, time, record].to_msgpack
|
62
|
+
end
|
63
|
+
|
64
|
+
def shutdown
|
65
|
+
super
|
66
|
+
end
|
67
|
+
|
68
|
+
def write(chunk)
|
69
|
+
chunk.msgpack_each do |tag, time, record|
|
70
|
+
begin
|
71
|
+
notify_sentry(tag, time, record)
|
72
|
+
rescue => e
|
73
|
+
$log.error("Sentry Error:", :error_class => e.class, :error => e.message)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def notify_sentry(tag, time, record)
|
79
|
+
level = record['level'] || @default_level
|
80
|
+
if not @report_levels.include?(level)
|
81
|
+
return
|
82
|
+
end
|
83
|
+
|
84
|
+
event = Raven::Event.new(
|
85
|
+
:configuration => @configuration,
|
86
|
+
:context => @context,
|
87
|
+
:timestamp => record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S'),
|
88
|
+
:level => level,
|
89
|
+
:logger => record['logger'] || @default_logger,
|
90
|
+
:message => record['message'] || record['msg'] || "",
|
91
|
+
)
|
92
|
+
event.tags = event.tags
|
93
|
+
.merge({ :fluentd_tag => tag })
|
94
|
+
.merge(extract_tags(record))
|
95
|
+
event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
96
|
+
@client.send_event(event)
|
97
|
+
end
|
98
|
+
|
99
|
+
def extract_tags(record, path=nil)
|
100
|
+
r = {}
|
101
|
+
record.each { |k, v|
|
102
|
+
kpath = path.nil? ? k : path + "." + k
|
103
|
+
if v.is_a?(Hash)
|
104
|
+
r.merge!(extract_tags(v, kpath))
|
105
|
+
else
|
106
|
+
if @tags_key.include?(kpath)
|
107
|
+
r[kpath] = v
|
108
|
+
end
|
109
|
+
end
|
110
|
+
}
|
111
|
+
return r
|
112
|
+
end
|
113
|
+
end
|
114
|
+
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_sentry'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'webmock/test_unit'
|
3
|
+
require 'yajl'
|
4
|
+
|
5
|
+
WebMock.disable_net_connect!
|
6
|
+
|
7
|
+
class SentryOutputTest < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
Fluent::Test.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
type sentry
|
14
|
+
endpoint_url https://user:password@app.getsentry.com/12345
|
15
|
+
hostname_command hostname -s
|
16
|
+
remove_tag_prefix input.
|
17
|
+
]
|
18
|
+
|
19
|
+
def create_driver(conf=CONFIG,tag='test',use_v1=false)
|
20
|
+
require 'fluent/version'
|
21
|
+
if Gem::Version.new(Fluent::VERSION) < Gem::Version.new('0.12')
|
22
|
+
Fluent::Test::OutputTestDriver.new(Fluent::SentryOutput, tag).configure(conf, use_v1)
|
23
|
+
else
|
24
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::SentryOutput, tag).configure(conf, use_v1)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def stub_post(url="https://app.getsentry.com/api/12345/store/")
|
29
|
+
parser = Yajl::Parser.new
|
30
|
+
stub_request(:post, url).with do |req|
|
31
|
+
@content_type = req.headers["Content-Type"]
|
32
|
+
message = Zlib::Inflate.inflate(Base64.decode64(req.body))
|
33
|
+
@body = parser.parse(message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def stub_response(url="https://app.getsentry.com/api/12345/store/")
|
38
|
+
stub_request(:post, url).with do |req|
|
39
|
+
@content_type = req.headers["Content-Type"]
|
40
|
+
message = Zlib::Inflate.inflate(Base64.decode64(req.body))
|
41
|
+
@body = {"eventID"=>"fe0263d6f55d014cade15a8681ae58ed", "tags"=>[["tag", "app1_error"], ["cool", "bar"], ["level", "warning"], ["logger", "zaphod"], ["server_name", "bc40a4be7b2d"], ["sentry:release", "wingnut"]], "nextEventID"=>nil, "dateCreated"=>"2015-10-30T08:25:48Z", "timeSpent"=>13, "user"=>nil, "entries"=>[], "previousEventID"=>nil, "message"=>"error has occoured.", "packages"=>{"fluentd"=>"0.12.16", "sentry-raven"=>"0.15.2", "cool.io"=>"1.4.1", "faraday"=>"0.9.2", "safe_yaml"=>"1.0.4", "msgpack"=>"0.5.12", "bundler"=>"1.10.6", "json"=>"1.8.3", "crack"=>"0.4.2", "tzinfo"=>"1.2.2", "thread_safe"=>"0.3.5", "tzinfo-data"=>"1.2015.7", "rake"=>"10.4.2", "yajl-ruby"=>"1.2.1", "hashdiff"=>"0.2.2", "sigdump"=>"0.2.3", "multipart-post"=>"2.0.0", "string-scrub"=>"0.0.5", "addressable"=>"2.3.8", "webmock"=>"1.22.2", "http_parser.rb"=>"0.6.0", "fluent-plugin-sentry"=>"0.0.1"}, "id"=>"127", "platform"=>"ruby", "context"=>{"something"=>{"foo"=>{"array"=>[1, 2, 3]}, "hash"=>{"nest"=>"data"}}}, "groupID"=>127}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_configure
|
46
|
+
assert_raise(Fluent::ConfigError) {
|
47
|
+
d = create_driver('')
|
48
|
+
}
|
49
|
+
d = create_driver(CONFIG)
|
50
|
+
assert_equal 'https://user:password@app.getsentry.com/12345', d.instance.config['endpoint_url']
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_emit
|
54
|
+
stub_post
|
55
|
+
d1 = create_driver(CONFIG, 'input.app1_error')
|
56
|
+
emit_level = 'warning'
|
57
|
+
emit_message = 'error has occoured.'
|
58
|
+
emit_extra = {'foo' => {'array' => [1,2,3]}, 'hash' => {'nest' => 'data'}}
|
59
|
+
d1.run do
|
60
|
+
d1.emit({
|
61
|
+
'level' => emit_level,
|
62
|
+
'message' => emit_message,
|
63
|
+
'something' => emit_extra
|
64
|
+
})
|
65
|
+
end
|
66
|
+
p @body
|
67
|
+
emits = d1.emits
|
68
|
+
timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S')
|
69
|
+
assert_equal 0, emits.length
|
70
|
+
assert_equal 'application/octet-stream', @content_type
|
71
|
+
assert_equal emit_message, @body['message']
|
72
|
+
assert_equal timestamp, @body['timestamp']
|
73
|
+
assert_equal emit_level, @body['level']
|
74
|
+
assert_equal 'fluentd', @body['logger']
|
75
|
+
assert_equal 'ruby', @body['platform']
|
76
|
+
assert_equal 'app1_error', @body['tags']['tag']
|
77
|
+
hostname = `#{d1.instance.config['hostname_command']}`.chomp
|
78
|
+
assert_equal hostname, @body['server_name']
|
79
|
+
extra_message = {'something' => emit_extra}
|
80
|
+
assert_equal extra_message, @body['extra']
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_emit_mock
|
84
|
+
stub_response
|
85
|
+
emit_level = 'warning'
|
86
|
+
emit_message = 'error has occoured.'
|
87
|
+
emit_timestamp = '2015-10-30T08:25:48Z'.force_encoding("UTF-8")
|
88
|
+
emit_time_spent = '13'
|
89
|
+
emit_logger = 'zaphod'
|
90
|
+
emit_server_name = 'bc40a4be7b2d'
|
91
|
+
emit_culprit = 'whodonit'
|
92
|
+
emit_release = 'wingnut'
|
93
|
+
emit_extra = {'foo' => {'array' => [1,2,3]}, 'hash' => {'nest' => 'data'}}
|
94
|
+
d1 = create_driver(CONFIG, 'input.app1_error')
|
95
|
+
d1.run do
|
96
|
+
d1.emit({
|
97
|
+
'level' => emit_level,
|
98
|
+
'message' => emit_message,
|
99
|
+
'something' => emit_extra,
|
100
|
+
'tags' => {'cool' => 'bar'},
|
101
|
+
'timestamp' => emit_timestamp,
|
102
|
+
'logger' => emit_logger,
|
103
|
+
'server_name' => emit_server_name,
|
104
|
+
'release' => emit_release,
|
105
|
+
'time_spent' => emit_time_spent,
|
106
|
+
'culprit' => emit_culprit
|
107
|
+
})
|
108
|
+
end
|
109
|
+
p @body
|
110
|
+
emits = d1.emits
|
111
|
+
extra_message = {'something' => emit_extra}
|
112
|
+
assert_equal 0, emits.length
|
113
|
+
assert_equal 'application/octet-stream', @content_type
|
114
|
+
assert_equal extra_message, @body['context']
|
115
|
+
assert_equal emit_timestamp, @body['dateCreated']
|
116
|
+
assert_equal emit_message, @body['message']
|
117
|
+
assert_equal emit_level, Hash[ @body['tags'] ]['level']
|
118
|
+
assert_equal emit_logger, Hash[ @body['tags'] ]['logger']
|
119
|
+
assert_equal emit_server_name, Hash[ @body['tags'] ]['server_name']
|
120
|
+
assert_equal emit_release, Hash[ @body['tags'] ]['sentry:release']
|
121
|
+
assert_equal 'bar', Hash[ @body['tags'] ]['cool']
|
122
|
+
assert_equal 'app1_error', Hash[ @body['tags'] ]['tag']
|
123
|
+
assert_equal 'ruby', @body['platform']
|
124
|
+
assert_equal nil, @body['user']
|
125
|
+
# these values seem to only be visible in the ui. need to find the api to grab them
|
126
|
+
#assert_equal emit_culprit, @body['culprit']
|
127
|
+
#assert_equal emit_time_spent, @body['timeSpent']
|
128
|
+
end
|
129
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-sentry-rubrik
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kentaro Yoshida
|
8
|
+
- François-Xavier Bourlet
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-02-24 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.16'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.16'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '12.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '12.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: webmock
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.3'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: test-unit
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.2'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: appraisal
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.2'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.2'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: fluentd
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.1'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.1'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: sentry-raven
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.7'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.7'
|
112
|
+
description:
|
113
|
+
email:
|
114
|
+
- y.ken.studio@gmail.com
|
115
|
+
- fx.bourlet@rubrik.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".travis.yml"
|
122
|
+
- Appraisals
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- fluent-plugin-sentry.gemspec
|
128
|
+
- gemfiles/fluentd_v0.10.gemfile
|
129
|
+
- gemfiles/fluentd_v0.12.gemfile
|
130
|
+
- lib/fluent/plugin/out_sentry.rb
|
131
|
+
- test/helper.rb
|
132
|
+
- test/plugin/test_out_sentry.rb
|
133
|
+
homepage: https://github.com/bombela/fluent-plugin-sentry
|
134
|
+
licenses:
|
135
|
+
- Apache-2.0
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.5.2.1
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Fluentd output plugin that sends aggregated errors/exception events to Sentry.
|
157
|
+
Sentry is a event logging and aggregation platform.
|
158
|
+
test_files:
|
159
|
+
- test/helper.rb
|
160
|
+
- test/plugin/test_out_sentry.rb
|