Commit 8300b3cd authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch 'bvl-api-feature-category-on-histogram' into 'master'

Add feature category to API latency histogram

See merge request gitlab-org/gitlab!49232
parents edebe968 38d5c760
...@@ -66,9 +66,10 @@ module Gitlab ...@@ -66,9 +66,10 @@ module Gitlab
if route if route
path = endpoint_paths_cache[route.request_method][route.path] path = endpoint_paths_cache[route.request_method][route.path]
# Feature categories will be added for grape endpoints in grape_class = endpoint.options[:for]
# https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/462 feature_category = grape_class.try(:feature_category_for_app, endpoint).to_s
{ controller: 'Grape', action: "#{route.request_method} #{path}", feature_category: '' }
{ controller: 'Grape', action: "#{route.request_method} #{path}", feature_category: feature_category }
end end
end end
......
...@@ -80,13 +80,15 @@ RSpec.describe Gitlab::Metrics::WebTransaction do ...@@ -80,13 +80,15 @@ RSpec.describe Gitlab::Metrics::WebTransaction do
context 'when request goes to Grape endpoint' do context 'when request goes to Grape endpoint' do
before do before do
route = double(:route, request_method: 'GET', path: '/:version/projects/:id/archive(.:format)') route = double(:route, request_method: 'GET', path: '/:version/projects/:id/archive(.:format)')
endpoint = double(:endpoint, route: route) endpoint = double(:endpoint, route: route,
options: { for: API::Projects, path: [":id/archive"] },
namespace: "/projects")
env['api.endpoint'] = endpoint env['api.endpoint'] = endpoint
end end
it 'provides labels with the method and path of the route in the grape endpoint' do it 'provides labels with the method and path of the route in the grape endpoint' do
expect(transaction.labels).to eq({ controller: 'Grape', action: 'GET /projects/:id/archive', feature_category: '' }) expect(transaction.labels).to eq({ controller: 'Grape', action: 'GET /projects/:id/archive', feature_category: 'projects' })
end end
it 'contains only the labels defined for transactions' do it 'contains only the labels defined for transactions' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment