Commit 526200ba authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Add addition instrumentation data into auth logs

parent 197132cd
......@@ -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
......
......@@ -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
......
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