Sha256: f200710fab34b673af7022c927195dbad83d15fa95c32941cafdf423de0530f7
Contents?: true
Size: 742 Bytes
Versions: 1
Compression:
Stored size: 742 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) method = env['REQUEST_METHOD'] metric_path = env['PATH_INFO'].nil? ? ".api" : env['PATH_INFO'].gsub("/", ".") request_path = env['api.endpoint'].routes.first.route_path[1..-1].gsub(/\(\.:format\)\z/, "") metric_name = "process_action.grape#{metric_path}" action = "#{method}#{metric_path}" 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.1.1 | lib/grape-appsignal/middleware.rb |