summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-05-16 12:34:31 +0000
committerNick Thomas <nick@gitlab.com>2018-05-16 12:34:31 +0000
commite5dc6b156ed032672fbefff33cfc84506cd21661 (patch)
treeea0f5c27297b7dd9ae0ce123fa4aa89bbc2a422b
parent51df79f891c262c7bdba61ad6931cb08cc37d7fb (diff)
parent33af33d7cbf947055a2a40dc2dddf74dfb13079c (diff)
downloadgitlab-ce-e5dc6b156ed032672fbefff33cfc84506cd21661.tar.gz
Merge branch 'fix-metrics-doorkeeper' into 'master'
Fix GitLab Performance Monitoring content types for Doorkeeper Closes #46412 See merge request gitlab-org/gitlab-ce!18984
-rw-r--r--lib/gitlab/metrics/web_transaction.rb6
-rw-r--r--spec/lib/gitlab/metrics/web_transaction_spec.rb6
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/gitlab/metrics/web_transaction.rb b/lib/gitlab/metrics/web_transaction.rb
index 7cf33ca9e8a..3799aaebf1c 100644
--- a/lib/gitlab/metrics/web_transaction.rb
+++ b/lib/gitlab/metrics/web_transaction.rb
@@ -28,7 +28,11 @@ module Gitlab
controller = @env[CONTROLLER_KEY]
action = "#{controller.action_name}"
- suffix = controller.request_format
+
+ # Devise exposes a method called "request_format" that does the below.
+ # However, this method is not available to all controllers (e.g. certain
+ # Doorkeeper controllers). As such we use the underlying code directly.
+ suffix = controller.request.format.try(:ref)
if suffix && suffix != :html
action += ".#{suffix}"
diff --git a/spec/lib/gitlab/metrics/web_transaction_spec.rb b/spec/lib/gitlab/metrics/web_transaction_spec.rb
index c07b33a039a..6eb0600f49e 100644
--- a/spec/lib/gitlab/metrics/web_transaction_spec.rb
+++ b/spec/lib/gitlab/metrics/web_transaction_spec.rb
@@ -180,11 +180,11 @@ describe Gitlab::Metrics::WebTransaction do
end
context 'when request goes to ActionController' do
- let(:request_format) { :html }
+ let(:request) { double(:request, format: double(:format, ref: :html)) }
before do
klass = double(:klass, name: 'TestController')
- controller = double(:controller, class: klass, action_name: 'show', request_format: request_format)
+ controller = double(:controller, class: klass, action_name: 'show', request: request)
env['action_controller.instance'] = controller
end
@@ -195,7 +195,7 @@ describe Gitlab::Metrics::WebTransaction do
end
context 'when the response content type is not :html' do
- let(:request_format) { :json }
+ let(:request) { double(:request, format: double(:format, ref: :json)) }
it 'appends the mime type to the transaction action' do
expect(transaction.labels).to eq({ controller: 'TestController', action: 'show.json' })