Sha256: be601d7df982f6d3b61c053300dd3c5c84807f65c81ee8f450ae86aed176e2c4

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

require 'grape'
require 'active_support'

module Appsignal
  module Grape
    class Middleware < ::Grape::Middleware::Base
      def initialize(app)
        @app = app
      end

      def call(env)
        req = ::Rack::Request.new(env)
        request_path = env['api.endpoint'].routes.first.route_path[1..-1].gsub(/\(\.:format\)\z/, "")
        metric_name  = "process_action.grape"
        ActiveSupport::Notifications.instrument(metric_name, { method: req.request_method, path: request_path } ) do |payload|
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-appsignal-0.0.3 lib/grape-appsignal/middleware.rb