fluent-plugin-sentry 0.0.1 → 0.0.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 +7 -0
- data/.travis.yml +2 -1
- data/README.md +18 -11
- data/fluent-plugin-sentry.gemspec +8 -4
- data/lib/fluent/plugin/out_sentry.rb +11 -10
- data/test/plugin/test_out_sentry.rb +61 -6
- metadata +38 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8bfaae537c17396c389b8ccd323104190294ccd6
|
4
|
+
data.tar.gz: d68fd5b98458bded9adf0f69733409ec78dffda3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 29e7dd065b655557f1e311881c2d2b937b69bf5dbad4e26948e6f137a250d4217134e8a07e6caffdfa8202ebfefc59bc0a2a4372a5c26c5de4f90fbfd47431fc
|
7
|
+
data.tar.gz: 6278d264c328045eed79c1037b6100d142888789cad79c78e6b983f238400dad2f7156f95900fa2d85ac37f4f1e8ebfad47c6409e9c1d0c451595e4d5a5c9a75
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,25 +2,30 @@
|
|
2
2
|
|
3
3
|
## Overview
|
4
4
|
|
5
|
-
|
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
6
|
|
7
|
-
|
8
|
-
|
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.
|
9
10
|
|
10
11
|
* [Sentry Official web](https://getsentry.com/welcome/)
|
11
12
|
* [Sentry Documents](http://sentry.readthedocs.org/en/latest/) [Screenshots](https://github.com/getsentry/sentry#screenshots)
|
12
13
|
|
14
|
+
> 
|
15
|
+
(quoted from http://blog.getsentry.com/)
|
16
|
+
|
17
|
+
|
13
18
|
## Installation
|
14
19
|
|
15
|
-
install with gem or fluent-gem command as:
|
20
|
+
install with `gem` or `fluent-gem` command as:
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
gem install fluent-plugin-sentry
|
22
|
+
```bash
|
23
|
+
# for fluentd
|
24
|
+
$ gem install fluent-plugin-sentry
|
20
25
|
|
21
|
-
|
22
|
-
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-sentry
|
23
|
-
|
26
|
+
# for td-agent
|
27
|
+
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-sentry
|
28
|
+
```
|
24
29
|
|
25
30
|
## Preparation
|
26
31
|
|
@@ -43,9 +48,10 @@ OR
|
|
43
48
|
type sentry
|
44
49
|
|
45
50
|
# Set endpoint API URL
|
46
|
-
endpoint_url https
|
51
|
+
endpoint_url https://API_KEY:API_PASSWORD@app.getsentry.com/PROJECT_ID
|
47
52
|
|
48
53
|
# Set default events value of 'server_name'
|
54
|
+
# To set short hostname, set like below.
|
49
55
|
hostname_command hostname -s
|
50
56
|
|
51
57
|
# rewrite shown tag name for Sentry dashboard
|
@@ -65,6 +71,7 @@ Set endpoint API URL which shows at Sentry dashboard. (it is not sentry account
|
|
65
71
|
[default] flunetd
|
66
72
|
|
67
73
|
* hostname_command<br>
|
74
|
+
[default] hostname
|
68
75
|
Set default frontend value of 'server_name'
|
69
76
|
|
70
77
|
* flush_interval<br>
|
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-sentry"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["Kentaro Yoshida"]
|
9
9
|
spec.email = ["y.ken.studio@gmail.com"]
|
10
|
-
spec.summary = %q{Fluentd output plugin
|
10
|
+
spec.summary = %q{Fluentd output plugin that sends aggregated errors/exception events to Sentry. Sentry is a event logging and aggregation platform.}
|
11
11
|
spec.homepage = "https://github.com/y-ken/fluent-plugin-sentry"
|
12
|
-
spec.license = "Apache
|
12
|
+
spec.license = "Apache-2.0"
|
13
13
|
|
14
14
|
spec.files = `git ls-files`.split($/)
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -19,6 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_development_dependency "bundler"
|
20
20
|
spec.add_development_dependency "rake"
|
21
21
|
spec.add_development_dependency "webmock"
|
22
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
|
23
|
+
spec.add_development_dependency "test-unit", '~> 3'
|
24
|
+
end
|
25
|
+
|
22
26
|
spec.add_runtime_dependency "fluentd"
|
23
|
-
spec.add_runtime_dependency "sentry-raven"
|
27
|
+
spec.add_runtime_dependency "sentry-raven", "~> 0.15.0"
|
24
28
|
end
|
@@ -4,7 +4,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
4
4
|
include Fluent::HandleTagNameMixin
|
5
5
|
|
6
6
|
LOG_LEVEL = %w(fatal error warning info debug)
|
7
|
-
EVENT_KEYS = %w(
|
7
|
+
EVENT_KEYS = %w(message timestamp time_spent level logger culprit server_name release tags)
|
8
8
|
DEFAULT_HOSTNAME_COMMAND = 'hostname'
|
9
9
|
|
10
10
|
config_param :default_level, :string, :default => 'error'
|
@@ -32,11 +32,11 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
32
32
|
end
|
33
33
|
|
34
34
|
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
|
35
|
-
hostname = `#{hostname_command}`.chomp
|
35
|
+
@hostname = `#{hostname_command}`.chomp
|
36
36
|
|
37
37
|
@configuration = Raven::Configuration.new
|
38
38
|
@configuration.server = @endpoint_url
|
39
|
-
@configuration.server_name = hostname
|
39
|
+
@configuration.server_name = @hostname
|
40
40
|
@client = Raven::Client.new(@configuration)
|
41
41
|
end
|
42
42
|
|
@@ -68,14 +68,15 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
68
68
|
:context => Raven::Context.new,
|
69
69
|
:message => record['message']
|
70
70
|
)
|
71
|
-
event.timestamp = Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
72
|
-
event.
|
71
|
+
event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
72
|
+
event.time_spent = record['time_spent'] || nil
|
73
73
|
event.level = record['level'] || @default_level
|
74
|
-
event.
|
74
|
+
event.logger = record['logger'] || @default_logger
|
75
|
+
event.culprit = record['culprit'] || nil
|
76
|
+
event.server_name = record['server_name'] || @hostname
|
77
|
+
event.release = record['release'] if record['release']
|
78
|
+
event.tags = event.tags.merge({ :tag => tag }.merge(record['tags'] || {}))
|
75
79
|
event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
76
|
-
event
|
77
|
-
event.platform = record['platform'] if record['platform']
|
78
|
-
event.server_name = record['server_name'] if record['server_name']
|
79
|
-
@client.send(event)
|
80
|
+
@client.send_event(event)
|
80
81
|
end
|
81
82
|
end
|
@@ -20,11 +20,20 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
20
20
|
Fluent::Test::OutputTestDriver.new(Fluent::SentryOutput, tag).configure(conf)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
23
|
+
def stub_post(url="https://app.getsentry.com/api/12345/store/")
|
24
24
|
parser = Yajl::Parser.new
|
25
25
|
stub_request(:post, url).with do |req|
|
26
26
|
@content_type = req.headers["Content-Type"]
|
27
|
-
|
27
|
+
message = Zlib::Inflate.inflate(Base64.decode64(req.body))
|
28
|
+
@body = parser.parse(message)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def stub_response(url="https://app.getsentry.com/api/12345/store/")
|
33
|
+
stub_request(:post, url).with do |req|
|
34
|
+
@content_type = req.headers["Content-Type"]
|
35
|
+
message = Zlib::Inflate.inflate(Base64.decode64(req.body))
|
36
|
+
@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}
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
@@ -37,7 +46,7 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
37
46
|
end
|
38
47
|
|
39
48
|
def test_emit
|
40
|
-
|
49
|
+
stub_post
|
41
50
|
d1 = create_driver(CONFIG, 'input.app1_error')
|
42
51
|
emit_level = 'warning'
|
43
52
|
emit_message = 'error has occoured.'
|
@@ -52,18 +61,64 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
52
61
|
p @body
|
53
62
|
emits = d1.emits
|
54
63
|
assert_equal 0, emits.length
|
55
|
-
assert_equal 'application/
|
64
|
+
assert_equal 'application/octet-stream', @content_type
|
56
65
|
assert_equal emit_message, @body['message']
|
57
66
|
timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S')
|
58
67
|
assert_equal timestamp, @body['timestamp']
|
59
68
|
assert_equal emit_level, @body['level']
|
60
|
-
assert_equal '12345', @body['project']
|
61
69
|
assert_equal 'fluentd', @body['logger']
|
62
70
|
assert_equal 'ruby', @body['platform']
|
63
|
-
assert_equal 'app1_error', @body['tags']['
|
71
|
+
assert_equal 'app1_error', @body['tags']['tag']
|
64
72
|
hostname = `#{d1.instance.config['hostname_command']}`.chomp
|
65
73
|
assert_equal hostname, @body['server_name']
|
66
74
|
extra_message = {'something' => emit_extra}
|
67
75
|
assert_equal extra_message, @body['extra']
|
68
76
|
end
|
77
|
+
|
78
|
+
def test_emit_mock
|
79
|
+
stub_response
|
80
|
+
emit_level = 'warning'
|
81
|
+
emit_message = 'error has occoured.'
|
82
|
+
emit_timestamp = '2015-10-30T08:25:48Z'.force_encoding("UTF-8")
|
83
|
+
emit_time_spent = '13'
|
84
|
+
emit_logger = 'zaphod'
|
85
|
+
emit_server_name = 'bc40a4be7b2d'
|
86
|
+
emit_culprit = 'whodonit'
|
87
|
+
emit_release = 'wingnut'
|
88
|
+
emit_extra = {'foo' => {'array' => [1,2,3]}, 'hash' => {'nest' => 'data'}}
|
89
|
+
d1 = create_driver(CONFIG, 'input.app1_error')
|
90
|
+
d1.run do
|
91
|
+
d1.emit({
|
92
|
+
'level' => emit_level,
|
93
|
+
'message' => emit_message,
|
94
|
+
'something' => emit_extra,
|
95
|
+
'tags' => {'cool' => 'bar'},
|
96
|
+
'timestamp' => emit_timestamp,
|
97
|
+
'logger' => emit_logger,
|
98
|
+
'server_name' => emit_server_name,
|
99
|
+
'release' => emit_release,
|
100
|
+
'time_spent' => emit_time_spent,
|
101
|
+
'culprit' => emit_culprit
|
102
|
+
})
|
103
|
+
end
|
104
|
+
p @body
|
105
|
+
emits = d1.emits
|
106
|
+
extra_message = {'something' => emit_extra}
|
107
|
+
assert_equal 0, emits.length
|
108
|
+
assert_equal 'application/octet-stream', @content_type
|
109
|
+
assert_equal extra_message, @body['context']
|
110
|
+
assert_equal emit_timestamp, @body['dateCreated']
|
111
|
+
assert_equal emit_message, @body['message']
|
112
|
+
assert_equal emit_level, Hash[ @body['tags'] ]['level']
|
113
|
+
assert_equal emit_logger, Hash[ @body['tags'] ]['logger']
|
114
|
+
assert_equal emit_server_name, Hash[ @body['tags'] ]['server_name']
|
115
|
+
assert_equal emit_release, Hash[ @body['tags'] ]['sentry:release']
|
116
|
+
assert_equal 'bar', Hash[ @body['tags'] ]['cool']
|
117
|
+
assert_equal 'app1_error', Hash[ @body['tags'] ]['tag']
|
118
|
+
assert_equal 'ruby', @body['platform']
|
119
|
+
assert_equal nil, @body['user']
|
120
|
+
# these values seem to only be visible in the ui. need to find the api to grab them
|
121
|
+
#assert_equal emit_culprit, @body['culprit']
|
122
|
+
#assert_equal emit_time_spent, @body['timeSpent']
|
123
|
+
end
|
69
124
|
end
|
metadata
CHANGED
@@ -1,96 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-sentry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kentaro Yoshida
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: webmock
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
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'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3'
|
62
69
|
- !ruby/object:Gem::Dependency
|
63
70
|
name: fluentd
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
72
|
requirements:
|
67
|
-
- -
|
73
|
+
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: '0'
|
70
76
|
type: :runtime
|
71
77
|
prerelease: false
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ">="
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
84
|
name: sentry-raven
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
|
-
- -
|
87
|
+
- - "~>"
|
84
88
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
89
|
+
version: 0.15.0
|
86
90
|
type: :runtime
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - "~>"
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
96
|
+
version: 0.15.0
|
94
97
|
description:
|
95
98
|
email:
|
96
99
|
- y.ken.studio@gmail.com
|
@@ -98,8 +101,8 @@ executables: []
|
|
98
101
|
extensions: []
|
99
102
|
extra_rdoc_files: []
|
100
103
|
files:
|
101
|
-
- .gitignore
|
102
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
103
106
|
- Gemfile
|
104
107
|
- LICENSE
|
105
108
|
- README.md
|
@@ -110,30 +113,29 @@ files:
|
|
110
113
|
- test/plugin/test_out_sentry.rb
|
111
114
|
homepage: https://github.com/y-ken/fluent-plugin-sentry
|
112
115
|
licenses:
|
113
|
-
- Apache
|
116
|
+
- Apache-2.0
|
117
|
+
metadata: {}
|
114
118
|
post_install_message:
|
115
119
|
rdoc_options: []
|
116
120
|
require_paths:
|
117
121
|
- lib
|
118
122
|
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
123
|
requirements:
|
121
|
-
- -
|
124
|
+
- - ">="
|
122
125
|
- !ruby/object:Gem::Version
|
123
126
|
version: '0'
|
124
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
128
|
requirements:
|
127
|
-
- -
|
129
|
+
- - ">="
|
128
130
|
- !ruby/object:Gem::Version
|
129
131
|
version: '0'
|
130
132
|
requirements: []
|
131
133
|
rubyforge_project:
|
132
|
-
rubygems_version:
|
134
|
+
rubygems_version: 2.4.5
|
133
135
|
signing_key:
|
134
|
-
specification_version:
|
135
|
-
summary: Fluentd output plugin
|
136
|
-
|
136
|
+
specification_version: 4
|
137
|
+
summary: Fluentd output plugin that sends aggregated errors/exception events to Sentry.
|
138
|
+
Sentry is a event logging and aggregation platform.
|
137
139
|
test_files:
|
138
140
|
- test/helper.rb
|
139
141
|
- test/plugin/test_out_sentry.rb
|