Sha256: 4c7b5382ef4124143361b2902b731b3888966131da3d065e589873148b34fd53

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

begin
  require 'new_relic/agent'
rescue LoadError
  raise "Can't find 'newrelic_rpm' gem. Please add it to your Gemfile or install it."
end

module GlassOctopus
  module Middleware
    class NewRelic
      include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

      DEFAULT_OPTIONS = {
        :name => "call",
        :category => "OtherTransaction/GlassOctopus",
      }.freeze

      def initialize(app, klass, options={})
        @app = app
        @options = DEFAULT_OPTIONS.merge(class_name: klass.name).merge(options)
      end

      def call(ctx)
        perform_action_with_newrelic_trace(@options) do
          @app.call(ctx)
        end
      rescue Exception => ex
        ::NewRelic::Agent.notice_error(ex, :custom_params => { :message => ctx.message.to_h })
        raise
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
glass_octopus-2.0.0 lib/glass_octopus/middleware/new_relic.rb
glass_octopus-1.1.0 lib/glass_octopus/middleware/new_relic.rb
glass_octopus-1.0.0 lib/glass_octopus/middleware/new_relic.rb