Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
189b063e
Commit
189b063e
authored
Sep 03, 2018
by
Andrew Newdigate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add route information to lograge structured logging
parent
91003c6e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
changelogs/unreleased/an-api-route-logger.yml
changelogs/unreleased/an-api-route-logger.yml
+5
-0
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/gitlab/grape_logging/loggers/route_logger.rb
lib/gitlab/grape_logging/loggers/route_logger.rb
+25
-0
No files found.
changelogs/unreleased/an-api-route-logger.yml
0 → 100644
View file @
189b063e
---
title
:
Add route information to lograge structured logging for API logs
merge_request
:
21487
author
:
type
:
other
lib/api/api.rb
View file @
189b063e
...
@@ -15,6 +15,7 @@ module API
...
@@ -15,6 +15,7 @@ module API
include:
[
include:
[
GrapeLogging
::
Loggers
::
FilterParameters
.
new
,
GrapeLogging
::
Loggers
::
FilterParameters
.
new
,
GrapeLogging
::
Loggers
::
ClientEnv
.
new
,
GrapeLogging
::
Loggers
::
ClientEnv
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
RouteLogger
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
UserLogger
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
UserLogger
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
QueueDurationLogger
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
QueueDurationLogger
.
new
,
Gitlab
::
GrapeLogging
::
Loggers
::
PerfLogger
.
new
Gitlab
::
GrapeLogging
::
Loggers
::
PerfLogger
.
new
...
...
lib/gitlab/grape_logging/loggers/route_logger.rb
0 → 100644
View file @
189b063e
# frozen_string_literal: true
# This grape_logging module (https://github.com/aserafin/grape_logging) makes it
# possible to log the details of the action
module
Gitlab
module
GrapeLogging
module
Loggers
class
RouteLogger
<
::
GrapeLogging
::
Loggers
::
Base
def
parameters
(
request
,
_
)
endpoint
=
request
.
env
[
Grape
::
Env
::
API_ENDPOINT
]
route
=
endpoint
&
.
route
&
.
pattern
&
.
origin
return
{}
unless
route
{
route:
route
}
rescue
# endpoint.route calls 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
end
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