Sha256: 187e8ed5d205531770ff95675b58759e6ee85eb334a063f812263d8c4bbe775c

Contents?: true

Size: 981 Bytes

Versions: 6

Compression:

Stored size: 981 Bytes

Contents

module Skylight
  # TODO: Handle filtering out notifications that we don't care about
  class Subscriber
    def self.register!(config=Config.new)
      ActiveSupport::Notifications.subscribe nil, new(config)
    end

    def initialize(config)
      @config = config
    end

    def start(name, id, payload)
      return unless trace = Trace.current

      name, title, desc, payload = Normalize.normalize(trace, name, payload, @config.normalizer)

      trace.start(name, title, desc, payload)
    end

    def finish(name, id, payload)
      return unless trace = Trace.current
      trace.stop
    end

    def measure(name, id, payload)
      return unless trace = Trace.current

      name, title, desc, payload = Normalize.normalize(trace, name, payload)

      trace.record(name, title, desc, payload)
    end

  private

    def controller_action(payload)
      "#{payload[:controller]}##{payload[:action]}"
    end

    def logger
      @config.logger
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
skylight-0.0.16 lib/skylight/subscriber.rb
skylight-0.0.15 lib/skylight/subscriber.rb
skylight-0.0.14 lib/skylight/subscriber.rb
skylight-0.0.13 lib/skylight/subscriber.rb
skylight-0.0.12 lib/skylight/subscriber.rb
skylight-0.0.11 lib/skylight/subscriber.rb