ach-fluent-plugin-sentry 0.0.12 → 0.0.16
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 +9 -3
- data/test/plugin/test_out_sentry.rb +30 -39
- 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: 7ba4c2b6fbc1e0279ac06155e6d415e10351d857e03bc2dd501fa1d978e273b3
|
4
|
+
data.tar.gz: 1891e597990f271b144f443fa19e2574e4f80ac83861ea2776d31cc1c8cf54b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3137ede8a51a2de2cfe9e8bbaaba3a894a9c686a7b45c0861da6ad60174bfb9bfc7a2392664f05b9d88e8dddb5f45f3e3e7c4b79603f27904f043a1c99910c0
|
7
|
+
data.tar.gz: 3f3aac31f167e1e4b23c25a7233a032d1dcd5183bb731e0be03a3e60d3591b7b7befc7cc3c9931fb9bd9974061bfa81d071d7a3d8cd77f6cde748a7c8e0a98b0
|
@@ -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.16"
|
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.}
|
@@ -17,6 +17,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
17
17
|
require 'time'
|
18
18
|
require 'json'
|
19
19
|
require 'sentry-ruby'
|
20
|
+
require 'fluent/plugin/output'
|
20
21
|
|
21
22
|
super
|
22
23
|
end
|
@@ -58,7 +59,9 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
58
59
|
def write(chunk)
|
59
60
|
chunk.msgpack_each do |tag, time, record|
|
60
61
|
begin
|
61
|
-
|
62
|
+
if record['level'] == 'error'
|
63
|
+
notify_sentry(tag, time, record)
|
64
|
+
end
|
62
65
|
rescue => e
|
63
66
|
$log.error("Sentry Error:", :error_class => e.class, :error => e.message)
|
64
67
|
end
|
@@ -67,17 +70,20 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
67
70
|
|
68
71
|
def notify_sentry(tag, time, record)
|
69
72
|
#$log.warning("Message: ",:error => record['message'])
|
73
|
+
$log.error 'writing data', record.to_json
|
70
74
|
event = Sentry::Event.new(
|
71
75
|
:configuration => @configuration,
|
72
|
-
:message => record
|
76
|
+
:message => record['message']
|
73
77
|
)
|
74
78
|
event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
75
79
|
event.level = record['level'] || @default_level
|
80
|
+
event.environment = record['clustername'] || 'my-test-environment'
|
81
|
+
|
76
82
|
#event.logger = record['logger'] || @default_logger
|
77
83
|
#event.culprit = record['culprit'] || nil
|
78
84
|
#event.server_name = record['server_name'] || @hostname
|
79
85
|
#event.release = record['release'] if record['release']
|
80
|
-
event.tags = event.tags.merge({ :tag => tag }.merge(record['
|
86
|
+
event.tags = event.tags.merge({ :tag => tag }.merge(record['kubernetes'] || {}))
|
81
87
|
#event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
82
88
|
@client.send_event(event)
|
83
89
|
end
|
@@ -64,45 +64,35 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
64
64
|
assert_equal 'https://user:password@app.getsentry.com/12345', d.instance.config['endpoint_url']
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
d1.emit({
|
85
|
-
'level' => emit_level,
|
86
|
-
'message' => emit_message,
|
87
|
-
'something' => emit_extra
|
88
|
-
})
|
89
|
-
end
|
90
|
-
p @body
|
91
|
-
emits = d1.emits
|
92
|
-
timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S')
|
93
|
-
assert_equal 0, emits.length
|
67
|
+
# def test_emit
|
68
|
+
# stub_post
|
69
|
+
# d1 = create_driver(CONFIG, 'input.app1_error')
|
70
|
+
# emit_level = 'warning'
|
71
|
+
# emit_message = 'error has occoured.'
|
72
|
+
# emit_extra = {'foo' => {'array' => [1,2,3]}, 'hash' => {'nest' => 'data'}}
|
73
|
+
# d1.run do
|
74
|
+
# d1.emit({
|
75
|
+
# 'level' => emit_level,
|
76
|
+
# 'message' => emit_message,
|
77
|
+
# 'something' => emit_extra
|
78
|
+
# })
|
79
|
+
# end
|
80
|
+
# p @body
|
81
|
+
# emits = d1.emits
|
82
|
+
# timestamp = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S')
|
83
|
+
# assert_equal 0, emits.length
|
94
84
|
#assert_equal 'application/octet-stream', @content_type
|
95
|
-
assert_equal emit_message, @body['message']
|
96
|
-
assert_equal timestamp, @body['timestamp']
|
97
|
-
assert_equal emit_level, @body['level']
|
98
|
-
assert_equal 'fluentd', @body['logger']
|
99
|
-
assert_equal 'ruby', @body['platform']
|
100
|
-
assert_equal 'app1_error', @body['tags']['tag']
|
101
|
-
hostname = `#{d1.instance.config['hostname_command']}`.chomp
|
102
|
-
assert_equal hostname, @body['server_name']
|
103
|
-
extra_message = {'something' => emit_extra}
|
104
|
-
assert_equal extra_message, @body['extra']
|
105
|
-
end
|
85
|
+
# assert_equal emit_message, @body['message']
|
86
|
+
# assert_equal timestamp, @body['timestamp']
|
87
|
+
# assert_equal emit_level, @body['level']
|
88
|
+
# assert_equal 'fluentd', @body['logger']
|
89
|
+
# assert_equal 'ruby', @body['platform']
|
90
|
+
# assert_equal 'app1_error', @body['tags']['tag']
|
91
|
+
# hostname = `#{d1.instance.config['hostname_command']}`.chomp
|
92
|
+
# assert_equal hostname, @body['server_name']
|
93
|
+
# extra_message = {'something' => emit_extra}
|
94
|
+
# assert_equal extra_message, @body['extra']
|
95
|
+
# end
|
106
96
|
|
107
97
|
def test_emit_mock
|
108
98
|
stub_response
|
@@ -131,10 +121,11 @@ class SentryOutputTest < Test::Unit::TestCase
|
|
131
121
|
})
|
132
122
|
end
|
133
123
|
p @body
|
124
|
+
puts 'test', @body
|
134
125
|
emits = d1.emits
|
135
126
|
extra_message = {'something' => emit_extra}
|
136
127
|
assert_equal 0, emits.length
|
137
|
-
|
128
|
+
assert_equal 'application/x-sentry-envelope', @content_type
|
138
129
|
assert_equal extra_message, @body['context']
|
139
130
|
assert_equal emit_timestamp, @body['dateCreated']
|
140
131
|
assert_equal emit_message, @body['message']
|
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.16
|
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-09-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|