summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-05-15 18:25:32 +0000
committerMek Stittri <mstittri@gitlab.com>2018-05-15 12:24:20 -0700
commitb3c2745cb6808bafbe2511765b5a90040c99f297 (patch)
treee30fc2eb08711c43f38a32e5ed5c8b656e0af721
parent9f121081d647b97565899171153011d5b0cf6914 (diff)
downloadgitlab-ce-b3c2745cb6808bafbe2511765b5a90040c99f297.tar.gz
Merge branch 'fix-metrics-content-types' into 'master'
Fix setting Gitlab metrics content types Closes gitlab-com/infrastructure#3499 See merge request gitlab-org/gitlab-ce!18975
-rw-r--r--changelogs/unreleased/fix-metrics-content-types.yml5
-rw-r--r--lib/gitlab/metrics/web_transaction.rb14
-rw-r--r--spec/lib/gitlab/metrics/web_transaction_spec.rb6
3 files changed, 9 insertions, 16 deletions
diff --git a/changelogs/unreleased/fix-metrics-content-types.yml b/changelogs/unreleased/fix-metrics-content-types.yml
new file mode 100644
index 00000000000..a418dccffc3
--- /dev/null
+++ b/changelogs/unreleased/fix-metrics-content-types.yml
@@ -0,0 +1,5 @@
+---
+title: Fix setting Gitlab metrics content types
+merge_request:
+author:
+type: fixed
diff --git a/lib/gitlab/metrics/web_transaction.rb b/lib/gitlab/metrics/web_transaction.rb
index 89ff02a96d6..7cf33ca9e8a 100644
--- a/lib/gitlab/metrics/web_transaction.rb
+++ b/lib/gitlab/metrics/web_transaction.rb
@@ -4,18 +4,6 @@ module Gitlab
CONTROLLER_KEY = 'action_controller.instance'.freeze
ENDPOINT_KEY = 'api.endpoint'.freeze
- CONTENT_TYPES = {
- 'text/html' => :html,
- 'text/plain' => :txt,
- 'application/json' => :json,
- 'text/js' => :js,
- 'application/atom+xml' => :atom,
- 'image/png' => :png,
- 'image/jpeg' => :jpeg,
- 'image/gif' => :gif,
- 'image/svg+xml' => :svg
- }.freeze
-
def initialize(env)
super()
@env = env
@@ -40,7 +28,7 @@ module Gitlab
controller = @env[CONTROLLER_KEY]
action = "#{controller.action_name}"
- suffix = CONTENT_TYPES[controller.content_type]
+ suffix = controller.request_format
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 1d162f53a13..c07b33a039a 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(:content_type) { 'text/html' }
+ let(:request_format) { :html }
before do
klass = double(:klass, name: 'TestController')
- controller = double(:controller, class: klass, action_name: 'show', content_type: content_type)
+ controller = double(:controller, class: klass, action_name: 'show', request_format: request_format)
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(:content_type) { 'application/json' }
+ let(:request_format) { :json }
it 'appends the mime type to the transaction action' do
expect(transaction.labels).to eq({ controller: 'TestController', action: 'show.json' })