ach-fluent-plugin-sentry 0.0.16 → 0.0.17
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 +6 -10
- metadata +1 -1
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
|
@@ -35,6 +37,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
35
37
|
|
36
38
|
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
|
37
39
|
@hostname = `#{hostname_command}`.chomp
|
40
|
+
@default_environment = DEFAULT_ENVIRONMENT
|
38
41
|
|
39
42
|
@configuration = Sentry::Configuration.new
|
40
43
|
@configuration.send_modules = false
|
@@ -59,7 +62,7 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
59
62
|
def write(chunk)
|
60
63
|
chunk.msgpack_each do |tag, time, record|
|
61
64
|
begin
|
62
|
-
if record['level'] == 'error'
|
65
|
+
if record.key?('level') and record['level'] == 'error'
|
63
66
|
notify_sentry(tag, time, record)
|
64
67
|
end
|
65
68
|
rescue => e
|
@@ -69,22 +72,15 @@ class Fluent::SentryOutput < Fluent::BufferedOutput
|
|
69
72
|
end
|
70
73
|
|
71
74
|
def notify_sentry(tag, time, record)
|
72
|
-
#$log.warning("Message: ",:error => record['message'])
|
73
|
-
$log.error 'writing data', record.to_json
|
74
75
|
event = Sentry::Event.new(
|
75
76
|
:configuration => @configuration,
|
76
77
|
:message => record['message']
|
77
78
|
)
|
78
79
|
event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
|
79
80
|
event.level = record['level'] || @default_level
|
80
|
-
event.environment = record['clustername'] ||
|
81
|
-
|
82
|
-
#event.logger = record['logger'] || @default_logger
|
83
|
-
#event.culprit = record['culprit'] || nil
|
84
|
-
#event.server_name = record['server_name'] || @hostname
|
85
|
-
#event.release = record['release'] if record['release']
|
81
|
+
event.environment = record['clustername'] || @default_environment
|
86
82
|
event.tags = event.tags.merge({ :tag => tag }.merge(record['kubernetes'] || {}))
|
87
|
-
|
83
|
+
event.contexts = event.contexts.merge(record['fields'])
|
88
84
|
@client.send_event(event)
|
89
85
|
end
|
90
86
|
end
|