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
if route
path = endpoint_paths_cache[route.request_method][route.path]
# Feature categories will be added for grape endpoints in
# https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/462
{ controller: 'Grape', action: "#{route.request_method} #{path}", feature_category: '' }
grape_class = endpoint.options[:for]
feature_category = grape_class.try(:feature_category_for_app, endpoint).to_s
{ controller: 'Grape', action: "#{route.request_method} #{path}", feature_category: feature_category }
end
end
......
......@@ -80,13 +80,15 @@ RSpec.describe Gitlab::Metrics::WebTransaction do
context 'when request goes to Grape endpoint' do
before do
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
end
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
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