Skip to content
Snippets Groups Projects
Commit 728441a4 authored by Stan Hu's avatar Stan Hu
Browse files

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
parents bdf279b1 c0033377
No related branches found
No related tags found
No related merge requests found
---
title: Fix setting Gitlab metrics content types
merge_request:
author:
type: fixed
Loading
Loading
@@ -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
Loading
Loading
@@ -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}"
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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' })
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment