Sha256: 89e805b248dd2a62f75060bb7a7a70980b92bff95ed2d29ba121e3c406b38b51
Contents?: true
Size: 708 Bytes
Versions: 1
Compression:
Stored size: 708 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) method = env['REQUEST_METHOD'] request_path = env['api.endpoint'].routes.first.route_path[1..-1].sub(/\(\.:format\)\z/, "") metric_name = "grape.#{req.request_method}.#{request_path}" action = "#{method} #{env['PATH_INFO']}" ActiveSupport::Notifications.instrument(metric_name, { method: method, path: request_path, action: action, class: "API" } ) 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.2.0 | lib/grape-appsignal/middleware.rb |