BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
bf8e174f
Commit
bf8e174f
authored
Jan 14, 2017
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '26587-metrics-middleware-endpoint-is-nil' into 'master'
Resolve "Metrics middleware: endpoint is nil" Closes #26587 See merge request !8544
parents
77756efc
892ff3a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
26587-metrics-middleware-endpoint-is-nil.yml
...s/unreleased/26587-metrics-middleware-endpoint-is-nil.yml
+4
-0
rack_middleware.rb
lib/gitlab/metrics/rack_middleware.rb
+11
-4
rack_middleware_spec.rb
spec/lib/gitlab/metrics/rack_middleware_spec.rb
+11
-0
No files found.
changelogs/unreleased/26587-metrics-middleware-endpoint-is-nil.yml
0 → 100644
View file @
bf8e174f
---
title
:
Check for env[Grape::Env::GRAPE_ROUTING_ARGS] instead of endpoint.route
merge_request
:
8544
author
:
lib/gitlab/metrics/rack_middleware.rb
View file @
bf8e174f
...
...
@@ -71,10 +71,17 @@ module Gitlab
def
tag_endpoint
(
trans
,
env
)
endpoint
=
env
[
ENDPOINT_KEY
]
# endpoint.route is nil in the case of a 405 response
if
endpoint
.
route
path
=
endpoint_paths_cache
[
endpoint
.
route
.
request_method
][
endpoint
.
route
.
path
]
trans
.
action
=
"Grape#
#{
endpoint
.
route
.
request_method
}
#{
path
}
"
begin
route
=
endpoint
.
route
rescue
# endpoint.route is calling env[Grape::Env::GRAPE_ROUTING_ARGS][:route_info]
# but env[Grape::Env::GRAPE_ROUTING_ARGS] is nil in the case of a 405 response
# so we're rescuing exceptions and bailing out
end
if
route
path
=
endpoint_paths_cache
[
route
.
request_method
][
route
.
path
]
trans
.
action
=
"Grape#
#{
route
.
request_method
}
#{
path
}
"
end
end
...
...
spec/lib/gitlab/metrics/rack_middleware_spec.rb
View file @
bf8e174f
...
...
@@ -126,5 +126,16 @@ describe Gitlab::Metrics::RackMiddleware do
expect
(
transaction
.
action
).
to
eq
(
'Grape#GET /projects/:id/archive'
)
end
it
'does not tag a transaction if route infos are missing'
do
endpoint
=
double
(
:endpoint
)
allow
(
endpoint
).
to
receive
(
:route
).
and_raise
env
[
'api.endpoint'
]
=
endpoint
middleware
.
tag_endpoint
(
transaction
,
env
)
expect
(
transaction
.
action
).
to
be_nil
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment