Commit 8e742e10 authored by Igor Wiedler's avatar Igor Wiedler

Propagate remote_ip through ApplicationContext for API requests

parent f20ee83e
...@@ -59,6 +59,7 @@ module API ...@@ -59,6 +59,7 @@ module API
project: -> { @project }, project: -> { @project },
namespace: -> { @group }, namespace: -> { @group },
caller_id: route.origin, caller_id: route.origin,
remote_ip: request.ip,
feature_category: feature_category feature_category: feature_category
) )
end end
......
...@@ -16,6 +16,7 @@ module API ...@@ -16,6 +16,7 @@ module API
user: -> { actor&.user }, user: -> { actor&.user },
project: -> { project }, project: -> { project },
caller_id: route.origin, caller_id: route.origin,
remote_ip: request.ip,
feature_category: feature_category feature_category: feature_category
) )
end end
......
...@@ -102,6 +102,7 @@ RSpec.describe API::API do ...@@ -102,6 +102,7 @@ RSpec.describe API::API do
Labkit::Context.current.to_h.tap do |log_context| Labkit::Context.current.to_h.tap do |log_context|
expect(log_context).to match('correlation_id' => an_instance_of(String), expect(log_context).to match('correlation_id' => an_instance_of(String),
'meta.caller_id' => '/api/:version/projects/:id/issues', 'meta.caller_id' => '/api/:version/projects/:id/issues',
'meta.remote_ip' => an_instance_of(String),
'meta.project' => project.full_path, 'meta.project' => project.full_path,
'meta.root_namespace' => project.namespace.full_path, 'meta.root_namespace' => project.namespace.full_path,
'meta.user' => user.username, 'meta.user' => user.username,
...@@ -117,6 +118,7 @@ RSpec.describe API::API do ...@@ -117,6 +118,7 @@ RSpec.describe API::API do
Labkit::Context.current.to_h.tap do |log_context| Labkit::Context.current.to_h.tap do |log_context|
expect(log_context).to match('correlation_id' => an_instance_of(String), expect(log_context).to match('correlation_id' => an_instance_of(String),
'meta.caller_id' => '/api/:version/users', 'meta.caller_id' => '/api/:version/users',
'meta.remote_ip' => an_instance_of(String),
'meta.feature_category' => 'users') 'meta.feature_category' => 'users')
end end
end 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