Sha256: 0615634c005f105b1a4ea79a93b4538fdeb748af58a9f57d675ab0f0720685e6

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

require 'airbrake'
require 'vx/common/amqp'
require 'active_support/notifications'

module Vx
  module Worker
    module AMQP
      Middleware = Struct.new(:app) do
        def call(env)
          prop = env[:properties] || {}
          head = prop[:headers] || {}

          Vx::Instrumentation.with("@fields" => head) do
            app.call(env)
          end
        end
      end
    end
  end
end

Vx::Common::AMQP.configure do |c|
  c.content_type = 'application/x-protobuf'
  c.instrumenter = ActiveSupport::Notifications
  c.on_error     = ->(e, env) {
    Vx::Instrumentation.handle_exception("worker", e, env)
    Airbrake.notify(e, env)
  }
  c.use :pub, Vx::Worker::AMQP::Middleware
  c.use :sub, Vx::Worker::AMQP::Middleware
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vx-worker-0.3.0.pre1 lib/vx/worker/initializers/amqp.rb