Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct x-forward-for #1007

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions discovery-provider/src/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def log_request(response): # pylint: disable=W0612
now = time.time()
duration = int((now - g.start) * 1000)
ip = request.headers.get('X-Forwarded-For', request.remote_addr)
ip = ip.split(',')[0].strip()
host = request.host.split(':', 1)[0]
args = request.query_string.decode("utf-8")

Expand Down
2 changes: 2 additions & 0 deletions discovery-provider/src/utils/redis_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def extract_app_name_key():
"""
application_name = request.args.get(app_name_param, type=str, default=None)
ip = request.headers.get('X-Forwarded-For', request.remote_addr)
ip = ip.split(',')[0].strip()
date_time = get_rounded_date_time().strftime(datetime_format)

application_key = f"{metrics_prefix}:{metrics_application}:{ip}:{date_time}"
Expand All @@ -84,6 +85,7 @@ def extract_route_key():
req_args = stringify_query_params(req_args)
route = f"{path}?{req_args}" if req_args else path
ip = request.headers.get('X-Forwarded-For', request.remote_addr)
ip = ip.split(',')[0].strip()
date_time = get_rounded_date_time().strftime(datetime_format)

route_key = f"{metrics_prefix}:{metrics_routes}:{ip}:{date_time}"
Expand Down