ach-fluent-plugin-sentry 0.0.8 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-sentry.gemspec +1 -1
- data/lib/fluent/plugin/out_sentry.rb +10 -6
- data/test/plugin/test_out_sentry.rb +26 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aff9ca9fa6de5b7d882fa769df71133580d7f4df6d01105e61c8f834ce47f78
|
4
|
+
data.tar.gz: ffa221398919720d1c36f49ff311e5c87d423773fab4755c711c36c21dbf7444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae217a992cc6122c50f4a061981fcbbb0aefd005d1a56057447ae1b4434e839834f68df99eaa5fab94e4b3d1d417afadeb3fed50e0a0a7a5976b45abcdd852d2
|
7
|
+
data.tar.gz: e0a23f26bf7206acd41a8e04136c50e024e70726bd68ea8fc9dab09e11f33510e1ad7826843eb4386adf37bdb636536c47fc19a3b7ea3d27b3f7be7566076395
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "ach-fluent-plugin-sentry"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.12"
|
8
8
|
spec.authors = ["Kentaro Yoshida"]
|
9
9
|
spec.email = ["y.ken.studio@gmail.com"]
|
10
10
|
spec.summary = %q{Fluentd output plugin that sends aggregated errors/exception events to Sentry. Sentry is a event logging and aggregation platform.}
|
@@ -15,6 +15,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
15
15
|
|
16
16
|
def initialize
|
17
17
|
require 'time'
|
18
|
+
require 'json'
|
18
19
|
require 'sentry-ruby'
|
19
20
|
|
20
21
|
super
|
@@ -35,6 +36,8 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
35
36
|
@hostname = `#{hostname_command}`.chomp
|
36
37
|
|
37
38
|
@configuration = Sentry::Configuration.new
|
39
|
+
@configuration.send_modules = false
|
40
|
+
@configuration.debug = true
|
38
41
|
@configuration.dsn = @endpoint_url
|
39
42
|
@configuration.server_name = @hostname
|
40
43
|
@client = Sentry::Client.new(@configuration)
|
@@ -63,18 +66,19 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
63
66
|
end
|
64
67
|
|
65
68
|
def notify_sentry(tag, time, record)
|
69
|
+
#$log.warning("Message: ",:error => record['message'])
|
66
70
|
event = Sentry::Event.new(
|
67
71
|
:configuration => @configuration,
|
68
|
-
:message => record
|
72
|
+
:message => record.to_json
|
69
73
|
)
|
70
74
|
event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
71
75
|
event.level = record['level'] || @default_level
|
72
|
-
event.logger = record['logger'] || @default_logger
|
73
|
-
event.culprit = record['culprit'] || nil
|
74
|
-
event.server_name = record['server_name'] || @hostname
|
75
|
-
event.release = record['release'] if record['release']
|
76
|
+
#event.logger = record['logger'] || @default_logger
|
77
|
+
#event.culprit = record['culprit'] || nil
|
78
|
+
#event.server_name = record['server_name'] || @hostname
|
79
|
+
#event.release = record['release'] if record['release']
|
76
80
|
event.tags = event.tags.merge({ :tag => tag }.merge(record['tags'] || {}))
|
77
|
-
event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
81
|
+
#event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
78
82
|
@client.send_event(event)
|
79
83
|
end
|
80
84
|
end
|
@@ -25,6 +25,20 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def stub_1(url="https://app.getsentry.com/api/12345/envelope/")
|
29
|
+
stub_request(:post, "https://app.getsentry.com/api/12345/envelope/").
|
30
|
+
with(
|
31
|
+
body: "{\"event_id\":\"2aa1f0210fc04c89a8febda09d3e4a5f\",\"dsn\":\"https://user:password@app.getsentry.com/12345\",\"sdk\":{\"name\":\"sentry.ruby\",\"version\":\"4.6.5\"},\"sent_at\":\"2021-09-01T12:00:23Z\"}\n{\"type\":\"event\",\"content_type\":\"application/json\"}\n{\"event_id\":\"2aa1f0210fc04c89a8febda09d3e4a5f\",\"level\":\"warning\",\"timestamp\":\"2021-09-01T12:00:23\",\"environment\":\"default\",\"server_name\":\"reisei-workspace\",\"modules\":{\"rake\":\"13.0.6\",\"bundler\":\"2.2.26\",\"cool.io\":\"1.7.1\",\"http_parser.rb\":\"0.7.0\",\"msgpack\":\"1.4.2\",\"sigdump\":\"0.2.4\",\"serverengine\":\"2.2.4\",\"strptime\":\"0.2.5\",\"concurrent-ruby\":\"1.1.9\",\"tzinfo\":\"2.0.4\",\"tzinfo-data\":\"1.2021.1\",\"webrick\":\"1.7.0\",\"yajl-ruby\":\"1.4.1\",\"fluentd\":\"1.14.0\",\"faraday-em_http\":\"1.0.0\",\"faraday-em_synchrony\":\"1.0.0\",\"faraday-excon\":\"1.1.0\",\"faraday-httpclient\":\"1.0.1\",\"faraday-net_http\":\"1.0.1\",\"faraday-net_http_persistent\":\"1.2.0\",\"faraday-patron\":\"1.0.0\",\"faraday-rack\":\"1.0.0\",\"multipart-post\":\"2.1.1\",\"ruby2_keywords\":\"0.0.5\",\"faraday\":\"1.7.0\",\"sentry-ruby-core\":\"4.6.5\",\"sentry-ruby\":\"4.6.5\",\"ach-fluent-plugin-sentry\":\"0.0.9\",\"public_suffix\":\"4.0.6\",\"addressable\":\"2.8.0\",\"thor\":\"1.1.0\",\"appraisal\":\"2.4.1\",\"rexml\":\"3.2.5\",\"crack\":\"0.4.5\",\"hashdiff\":\"1.0.1\",\"power_assert\":\"2.0.1\",\"test-unit\":\"3.4.4\",\"webmock\":\"3.14.0\"},\"message\":\"error has occoured.\",\"user\":{},\"tags\":{\"tag\":\"app1_error\"},\"contexts\":{},\"extra\":{},\"fingerprint\":[],\"platform\":\"ruby\",\"sdk\":{\"name\":\"sentry.ruby\",\"version\":\"4.6.5\"}}\n",
|
32
|
+
headers: {
|
33
|
+
'Accept'=>'*/*',
|
34
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
35
|
+
'Content-Encoding'=>'',
|
36
|
+
'Content-Type'=>'application/x-sentry-envelope',
|
37
|
+
'User-Agent'=>'sentry-ruby/4.6.5',
|
38
|
+
'X-Sentry-Auth'=>'Sentry sentry_version=7, sentry_client=sentry-ruby/4.6.5, sentry_timestamp=1630497623, sentry_key=user, sentry_secret=password'
|
39
|
+
}).to_return(status: 200, body: "", headers: {})
|
40
|
+
end
|
41
|
+
|
28
42
|
def stub_post(url="https://app.getsentry.com/api/12345/store/")
|
29
43
|
parser = Yajl::Parser.new
|
30
44
|
stub_request(:post, url).with do |req|
|
@@ -34,7 +48,7 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
37
|
-
def stub_response(url="https://app.getsentry.com/api/12345/
|
51
|
+
def stub_response(url="https://app.getsentry.com/api/12345/envelope/")
|
38
52
|
stub_request(:post, url).with do |req|
|
39
53
|
@content_type = req.headers["Content-Type"]
|
40
54
|
message = Zlib::Inflate.inflate(Base64.decode64(req.body))
|
@@ -51,7 +65,17 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
51
65
|
end
|
52
66
|
|
53
67
|
def test_emit
|
54
|
-
|
68
|
+
stub_request(:post, "https://app.getsentry.com/api/12345/envelope/").
|
69
|
+
with(
|
70
|
+
body: "{\"event_id\":\"2aa1f0210fc04c89a8febda09d3e4a5f\",\"dsn\":\"https://user:password@app.getsentry.com/12345\",\"sdk\":{\"name\":\"sentry.ruby\",\"version\":\"4.6.5\"},\"sent_at\":\"2021-09-01T12:00:23Z\"}\n{\"type\":\"event\",\"content_type\":\"application/json\"}\n{\"event_id\":\"2aa1f0210fc04c89a8febda09d3e4a5f\",\"level\":\"warning\",\"timestamp\":\"2021-09-01T12:00:23\",\"environment\":\"default\",\"server_name\":\"reisei-workspace\",\"modules\":{\"rake\":\"13.0.6\",\"bundler\":\"2.2.26\",\"cool.io\":\"1.7.1\",\"http_parser.rb\":\"0.7.0\",\"msgpack\":\"1.4.2\",\"sigdump\":\"0.2.4\",\"serverengine\":\"2.2.4\",\"strptime\":\"0.2.5\",\"concurrent-ruby\":\"1.1.9\",\"tzinfo\":\"2.0.4\",\"tzinfo-data\":\"1.2021.1\",\"webrick\":\"1.7.0\",\"yajl-ruby\":\"1.4.1\",\"fluentd\":\"1.14.0\",\"faraday-em_http\":\"1.0.0\",\"faraday-em_synchrony\":\"1.0.0\",\"faraday-excon\":\"1.1.0\",\"faraday-httpclient\":\"1.0.1\",\"faraday-net_http\":\"1.0.1\",\"faraday-net_http_persistent\":\"1.2.0\",\"faraday-patron\":\"1.0.0\",\"faraday-rack\":\"1.0.0\",\"multipart-post\":\"2.1.1\",\"ruby2_keywords\":\"0.0.5\",\"faraday\":\"1.7.0\",\"sentry-ruby-core\":\"4.6.5\",\"sentry-ruby\":\"4.6.5\",\"ach-fluent-plugin-sentry\":\"0.0.9\",\"public_suffix\":\"4.0.6\",\"addressable\":\"2.8.0\",\"thor\":\"1.1.0\",\"appraisal\":\"2.4.1\",\"rexml\":\"3.2.5\",\"crack\":\"0.4.5\",\"hashdiff\":\"1.0.1\",\"power_assert\":\"2.0.1\",\"test-unit\":\"3.4.4\",\"webmock\":\"3.14.0\"},\"message\":\"error has occoured.\",\"user\":{},\"tags\":{\"tag\":\"app1_error\"},\"contexts\":{},\"extra\":{},\"fingerprint\":[],\"platform\":\"ruby\",\"sdk\":{\"name\":\"sentry.ruby\",\"version\":\"4.6.5\"}}\n",
|
71
|
+
headers: {
|
72
|
+
'Accept'=>'*/*',
|
73
|
+
'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
74
|
+
'Content-Encoding'=>'',
|
75
|
+
'Content-Type'=>'application/x-sentry-envelope',
|
76
|
+
'User-Agent'=>'sentry-ruby/4.6.5',
|
77
|
+
'X-Sentry-Auth'=>'Sentry sentry_version=7, sentry_client=sentry-ruby/4.6.5, sentry_timestamp=1630497623, sentry_key=user, sentry_secret=password'}).to_return(status: 200, body: "", headers: {})
|
78
|
+
#stub_post
|
55
79
|
d1 = create_driver(CONFIG, 'input.app1_error')
|
56
80
|
emit_level = 'warning'
|
57
81
|
emit_message = 'error has occoured.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ach-fluent-plugin-sentry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kentaro Yoshida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|