Make IP resolver performance a bit better by skipping an unnecessary set

This will still hang for a second or two on first call
This commit is contained in:
Joseph Schorr 2018-08-08 14:40:26 -04:00
parent c7baf6cf58
commit b7d8bb227e
2 changed files with 8 additions and 9 deletions

View file

@ -45,7 +45,7 @@ def track_and_log(event_name, repo_obj, analytics_name=None, analytics_sample=1,
if analytics_name is None:
analytics_name = event_name
logger.debug('Logging the %s to Mixpanel', analytics_name)
logger.debug('Logging the %s to analytics engine', analytics_name)
request_parsed = urlparse(request.url_root)
extra_params = {
@ -57,10 +57,13 @@ def track_and_log(event_name, repo_obj, analytics_name=None, analytics_sample=1,
analytics.track(analytics_id, analytics_name, extra_params)
# Add the resolved information to the metadata.
logger.debug('Resolving IP address %s', request.remote_addr)
resolved_ip = ip_resolver.resolve_ip(request.remote_addr)
if resolved_ip is not None:
metadata['resolved_ip'] = resolved_ip._asdict()
logger.debug('Resolved IP address %s', request.remote_addr)
# Log the action to the database.
logger.debug('Logging the %s to logs system', event_name)
model.log.log_action(event_name, namespace_name, performer=get_authenticated_user(),