Sha256: 65dacf3f66ea7f0ceec95d9ba420b26e1ec850a08a41fb24cbdff3b59d115076

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'active_support'
require 'active_support/core_ext/object/blank'

module HermesMessengerOfTheGods
  module Concerns
    module Base
      extend ActiveSupport::Concern

      include EndpointBuilder::Helpers
      include LoggingHelpers

      included do
        def instrument(name, payload = {}, &blk)
          name = [
            'hermes_messenger_of_the_gods',
            notification_prefix,
            name
          ].reject(&:blank?).join('.')

          payload[_instrument_key] ||= self if _instrument_key
          ActiveSupport::Notifications.instrument(name, payload, &blk)
        end

        def notification_prefix
          _instrument_key
        end

        def _instrument_key
          if is_a?(HermesMessengerOfTheGods::Concerns::Worker)
            :worker
          elsif is_a?(HermesMessengerOfTheGods::Concerns::Message)
            :message
          elsif is_a?(HermesMessengerOfTheGods::Endpoints::Base)
            :endpoint
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hermes_messenger_of_the_gods-2.4.0.pre2 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.4.0.pre1 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.3.4 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.3.3 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.3.2 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.3.1 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.3.0 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.2.0 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.1.1 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.1.0 lib/hermes_messenger_of_the_gods/concerns/base.rb
hermes_messenger_of_the_gods-2.0.0 lib/hermes_messenger_of_the_gods/concerns/base.rb