lib/fluent/plugin/out_sentry.rb in fluent-plugin-sentry-0.0.1 vs lib/fluent/plugin/out_sentry.rb in fluent-plugin-sentry-0.0.2
- old
+ new
@@ -2,11 +2,11 @@
Fluent::Plugin.register_output('sentry', self)
include Fluent::HandleTagNameMixin
LOG_LEVEL = %w(fatal error warning info debug)
- EVENT_KEYS = %w(logger level tags modules message)
+ EVENT_KEYS = %w(message timestamp time_spent level logger culprit server_name release tags)
DEFAULT_HOSTNAME_COMMAND = 'hostname'
config_param :default_level, :string, :default => 'error'
config_param :default_logger, :string, :default => 'fluentd'
config_param :endpoint_url, :string
@@ -30,15 +30,15 @@
unless LOG_LEVEL.include?(@default_level)
raise Fluent::ConfigError, "sentry: unsupported default reporting log level for 'default_level'"
end
hostname_command = @hostname_command || DEFAULT_HOSTNAME_COMMAND
- hostname = `#{hostname_command}`.chomp
+ @hostname = `#{hostname_command}`.chomp
@configuration = Raven::Configuration.new
@configuration.server = @endpoint_url
- @configuration.server_name = hostname
+ @configuration.server_name = @hostname
@client = Raven::Client.new(@configuration)
end
def start
super
@@ -66,16 +66,17 @@
event = Raven::Event.new(
:configuration => @configuration,
:context => Raven::Context.new,
:message => record['message']
)
- event.timestamp = Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
- event.logger = record['logger'] || @default_logger
+ event.timestamp = record['timestamp'] || Time.at(time).utc.strftime('%Y-%m-%dT%H:%M:%S')
+ event.time_spent = record['time_spent'] || nil
event.level = record['level'] || @default_level
- event.tags = record['tags'] || { :tag => tag }
+ event.logger = record['logger'] || @default_logger
+ event.culprit = record['culprit'] || nil
+ event.server_name = record['server_name'] || @hostname
+ event.release = record['release'] if record['release']
+ event.tags = event.tags.merge({ :tag => tag }.merge(record['tags'] || {}))
event.extra = record.reject{ |key| EVENT_KEYS.include?(key) }
- event.modules = record['modules'] || nil
- event.platform = record['platform'] if record['platform']
- event.server_name = record['server_name'] if record['server_name']
- @client.send(event)
+ @client.send_event(event)
end
end