ach-fluent-plugin-sentry 0.0.13 → 0.0.17
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 +4 -4
- data/fluent-plugin-sentry.gemspec +1 -1
- data/lib/fluent/plugin/out_sentry.rb +11 -10
- 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: d11309811e7cccf0b4fb45330d9ff6d3bcd804ebfb6ec51249f3c2c8fac7dc43
|
4
|
+
data.tar.gz: 686f447c43253200c43962d2f9a1aa551232178c8e4e014c7415b1fac9201bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65d08153aea4aadb0b003910549ba62efe407126c23c492fade155534550f6d45da8e225be112b3b30bb6eadb62555e0b90cbc5678f53a095ab7a96226473e9c
|
7
|
+
data.tar.gz: 0d78501d55d49d889ad31fafbff0fd54a40531a7ac1d43002bd495a070df4239ba3056be8c6da537c454c48f1853fa7c5315606b5cdd7662d108b8513136f1ba
|
@@ -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.17"
|
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.}
|
@@ -6,8 +6,10 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
6
6
|
LOG_LEVEL = %w(fatal error warning info debug)
|
7
7
|
EVENT_KEYS = %w(message timestamp time_spent level logger culprit server_name release tags)
|
8
8
|
DEFAULT_HOSTNAME_COMMAND = 'hostname'
|
9
|
+
DEFAULT_ENVIRONMENT = 'default'
|
9
10
|
|
10
11
|
config_param :default_level, :string, :default => 'error'
|
12
|
+
config_param :default_environment, :string, :default => 'default'
|
11
13
|
config_param :default_logger, :string, :default => 'fluentd'
|
12
14
|
config_param :endpoint_url, :string
|
13
15
|
config_param :flush_interval, :time, :default => 0
|
@@ -17,6 +19,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
17
19
|
require 'time'
|
18
20
|
require 'json'
|
19
21
|
require 'sentry-ruby'
|
22
|
+
require 'fluent/plugin/output'
|
20
23
|
|
21
24
|
super
|
22
25
|
end
|
@@ -34,6 +37,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
34
37
|
|
35
38
|
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
|
36
39
|
@hostname = `#{hostname_command}`.chomp
|
40
|
+
@default_environment = DEFAULT_ENVIRONMENT
|
37
41
|
|
38
42
|
@configuration = Sentry::Configuration.new
|
39
43
|
@configuration.send_modules = false
|
@@ -58,7 +62,9 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
58
62
|
def write(chunk)
|
59
63
|
chunk.msgpack_each do |tag, time, record|
|
60
64
|
begin
|
61
|
-
|
65
|
+
if record.key?('level') and record['level'] == 'error'
|
66
|
+
notify_sentry(tag, time, record)
|
67
|
+
end
|
62
68
|
rescue => e
|
63
69
|
$log.error("Sentry Error:", :error_class => e.class, :error => e.message)
|
64
70
|
end
|
@@ -66,20 +72,15 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
66
72
|
end
|
67
73
|
|
68
74
|
def notify_sentry(tag, time, record)
|
69
|
-
#$log.warning("Message: ",:error => record['message'])
|
70
|
-
$log.debug 'writing data', record.to_json
|
71
75
|
event = Sentry::Event.new(
|
72
76
|
:configuration => @configuration,
|
73
|
-
:message => record['
|
77
|
+
:message => record['message']
|
74
78
|
)
|
75
79
|
event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
76
80
|
event.level = record['level'] || @default_level
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
#event.release = record['release'] if record['release']
|
81
|
-
event.tags = event.tags.merge({ :tag => tag }.merge(record['tags'] || {}))
|
82
|
-
#event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
|
81
|
+
event.environment = record['clustername'] || @default_environment
|
82
|
+
event.tags = event.tags.merge({ :tag => tag }.merge(record['kubernetes'] || {}))
|
83
|
+
event.contexts = event.contexts.merge(record['fields'])
|
83
84
|
@client.send_event(event)
|
84
85
|
end
|
85
86
|
end
|
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.17
|
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
|