diff --git a/lib/puppet/reports/sentry.rb b/lib/puppet/reports/sentry.rb index cc9c4a8..b78994d 100644 --- a/lib/puppet/reports/sentry.rb +++ b/lib/puppet/reports/sentry.rb @@ -1,6 +1,5 @@ require 'puppet' require 'yaml' -# require 'pp' begin require 'rubygems' @@ -9,23 +8,22 @@ end begin - require 'raven' + require 'sentry-ruby' rescue LoadError => e - Puppet.err "You need the `sentry-raven` gem installed on the puppetmaster to send reports to Sentry" + Puppet.err "You need the `sentry-ruby` gem installed on the puppetmaster to send reports to Sentry" end - Puppet::Reports.register_report(:sentry) do # Description - desc = 'Puppet reporter designed to send failed runs to a sentry server' - + desc = 'Puppet reporter designed to send failed runs to a Sentry server' + # Those are the log levels used by Puppet::Util::Log # @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit] # (https://github.com/puppetlabs/puppet/blob/3f1bbd2ec31bc7be8a7626c23de8089ee638bad4/lib/puppet/util/log.rb#L16) # Those are the log levels we want to have alerts for: - # Nothing that is less that :info should go to Sentry + # Nothing that is less than :info should go to Sentry ALERT_ON = [:warning,:err,:alert,:emerg,:crit] - + # Load the config else error # The file sentry.yaml should be in the root of the environment config_path = File.join([File.dirname(Puppet.settings[:config]), "sentry.yaml"]) @@ -58,7 +56,7 @@ def process @host = self.host end - + if self.respond_to?(:puppet_version) @puppet_version = self.puppet_version end @@ -67,29 +65,28 @@ def process @status = self.status end - # Configure raven - Raven.configure do |config| - config.dsn = CONFIG[:sentry_dsn] - config.current_environment = @environment - end - - # Get the important looking stuff to sentry - # pp self - self.logs.each do |log| - if ALERT_ON.include? log.level - Raven.captureMessage(log.message, { - :server_name => @host, - :tags => { - 'status' => @status, - 'version' => @puppet_version, - }, - :extra => { - 'source' => log.source, - 'line' => log.line, - 'file' => log.file, - }, - }) - end - end - end + # Initialize Sentry with DSN and current environment + Sentry.init do |config| + config.dsn = CONFIG[:sentry_dsn] + config.environment = @environment + end + + # Get the important looking stuff to Sentry + self.logs.each do |log| + if ALERT_ON.include?(log.level) + Sentry.capture_message(log.message, { + server_name: @host, + tags: { + 'status' => @status, + 'version' => @puppet_version + }, + extra: { + 'source' => log.source, + 'line' => log.line, + 'file' => log.file + } + }) + end + end + end end