diff --git a/changelogs/unreleased/26051-fix-missing-endpoint-route-method.yml b/changelogs/unreleased/26051-fix-missing-endpoint-route-method.yml
new file mode 100644
index 0000000000000000000000000000000000000000..85440eb86f9f2dae009c36c101b1acdc11e25f18
--- /dev/null
+++ b/changelogs/unreleased/26051-fix-missing-endpoint-route-method.yml
@@ -0,0 +1,4 @@
+---
+title: Don't instrument 405 Grape calls
+merge_request: 8445
+author:
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 9d5adffd8f4510864137aec6129edbfd0e129499..6cf6b501021925b01bb495eaf059b02590253e53 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -14,7 +14,11 @@ module API
     end
 
     # Retain 405 error rather than a 500 error for Grape 0.15.0+.
-    # See: https://github.com/ruby-grape/grape/commit/252bfd27c320466ec3c0751812cf44245e97e5de
+    # https://github.com/ruby-grape/grape/blob/a3a28f5b5dfbb2797442e006dbffd750b27f2a76/UPGRADING.md#changes-to-method-not-allowed-routes
+    rescue_from Grape::Exceptions::MethodNotAllowed do |e|
+      error! e.message, e.status, e.headers
+    end
+
     rescue_from Grape::Exceptions::Base do |e|
       error! e.message, e.status, e.headers
     end
diff --git a/lib/ci/api/api.rb b/lib/ci/api/api.rb
index a6b9beecded18128ccd4ee5d3b7217e05918edff..24bb3649a7673cd3b56a390462ea151299cc0c9a 100644
--- a/lib/ci/api/api.rb
+++ b/lib/ci/api/api.rb
@@ -8,6 +8,16 @@ module Ci
         rack_response({ 'message' => '404 Not found' }.to_json, 404)
       end
 
+      # Retain 405 error rather than a 500 error for Grape 0.15.0+.
+      # https://github.com/ruby-grape/grape/blob/a3a28f5b5dfbb2797442e006dbffd750b27f2a76/UPGRADING.md#changes-to-method-not-allowed-routes
+      rescue_from Grape::Exceptions::MethodNotAllowed do |e|
+        error! e.message, e.status, e.headers
+      end
+
+      rescue_from Grape::Exceptions::Base do |e|
+        error! e.message, e.status, e.headers
+      end
+
       rescue_from :all do |exception|
         handle_api_exception(exception)
       end
diff --git a/lib/gitlab/metrics/rack_middleware.rb b/lib/gitlab/metrics/rack_middleware.rb
index 91fb0bb317a6200ed505a4b462f6cc8e0dbb68dd..d01d47a6a7a833ccb866e3c3caef71146d97fb92 100644
--- a/lib/gitlab/metrics/rack_middleware.rb
+++ b/lib/gitlab/metrics/rack_middleware.rb
@@ -70,8 +70,12 @@ module Gitlab
 
       def tag_endpoint(trans, env)
         endpoint = env[ENDPOINT_KEY]
-        path = endpoint_paths_cache[endpoint.route.request_method][endpoint.route.path]
-        trans.action = "Grape##{endpoint.route.request_method} #{path}"
+
+        # endpoint.route is nil in the case of a 405 response
+        if endpoint.route
+          path = endpoint_paths_cache[endpoint.route.request_method][endpoint.route.path]
+          trans.action = "Grape##{endpoint.route.request_method} #{path}"
+        end
       end
 
       private