bolshakov / stoplight

:traffic_light: Traffic control for code.
http://bolshakov.github.io/stoplight/
MIT License
384 stars 40 forks source link

Raven has been replaced by Sentry-ruby gem. Interface has changed #156

Closed davidcarlin-ap closed 1 year ago

davidcarlin-ap commented 2 years ago

See: https://github.com/getsentry/sentry-ruby#migrate-from-sentry-raven

Can we please get a notifier for Sentry?

davidcarlin-ap commented 2 years ago

Could be something like this

module Stoplight
  module Notifier
    # @see Base
    class Sentry < Base
      DEFAULT_OPTIONS = {
        extra: {}
      }.freeze

      # @return [::Sentry]
      attr_reader :sentry
      # @return [Proc]
      attr_reader :formatter
      # @return [Hash{Symbol => Object}]
      attr_reader :options

      # @param api_key [String]
      # @param formatter [Proc, nil]
      # @param options [Hash{Symbol => Object}]
      # @option options [Hash] :extra
      def initialize(sentry, formatter = nil, options = {})
        @sentry = sentry
        @formatter = formatter || Default::FORMATTER
        @options = DEFAULT_OPTIONS.merge(options)
      end

      def notify(light, from_color, to_color, error)
        message = formatter.call(light, from_color, to_color, error)

        h = options.merge(
          backtrace: error&.backtrace
        )
        sentry.capture_message(message, **h)
        message
      end
    end
  end
end
davidcarlin-ap commented 2 years ago

Note that it doesn't take the configuration as an option and we need to double splat the option hash (**h)

bolshakov commented 1 year ago

I think it's time to reconsider the future of notifiers https://github.com/bolshakov/stoplight/issues/163

bolshakov commented 1 year ago

It's done. I've just dropped all the notifiers from the Stoplight codebase. https://github.com/bolshakov/stoplight/pull/174 However, we plan to provide stoplight-sentry gem as an example of an external notifier.

https://github.com/bolshakov/stoplight/issues/178