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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
526200ba
Commit
526200ba
authored
Jan 25, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add addition instrumentation data into auth logs
parent
197132cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
21 deletions
+29
-21
lib/gitlab/metrics/subscribers/rack_attack.rb
lib/gitlab/metrics/subscribers/rack_attack.rb
+2
-0
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
+27
-21
No files found.
lib/gitlab/metrics/subscribers/rack_attack.rb
View file @
526200ba
...
...
@@ -77,6 +77,8 @@ module Gitlab
rack_attack_info
[
'meta.user'
]
=
user
.
username
unless
user
.
nil?
end
Gitlab
::
InstrumentationHelper
.
add_instrumentation_data
(
rack_attack_info
)
logger
.
error
(
rack_attack_info
)
end
...
...
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
View file @
526200ba
...
...
@@ -78,12 +78,14 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
it
'logs request information'
do
expect
(
Gitlab
::
AuthLogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_unauthenticated'
include
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_unauthenticated'
)
)
subscriber
.
send
(
match_type
,
event
)
end
...
...
@@ -109,13 +111,15 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
it
'logs request information and user id'
do
expect
(
Gitlab
::
AuthLogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_authenticated_api'
,
user_id:
'not_exist_user_id'
include
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_authenticated_api'
,
user_id:
'not_exist_user_id'
)
)
subscriber
.
send
(
match_type
,
event
)
end
...
...
@@ -141,14 +145,16 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
it
'logs request information and user meta'
do
expect
(
Gitlab
::
AuthLogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_authenticated_api'
,
user_id:
user
.
id
,
'meta.user'
=>
user
.
username
include
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
request_method:
'GET'
,
path:
'/api/v4/internal/authorized_keys'
,
matched:
'throttle_authenticated_api'
,
user_id:
user
.
id
,
'meta.user'
=>
user
.
username
)
)
subscriber
.
send
(
match_type
,
event
)
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