Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #289 from mozilla-services/180
Browse files Browse the repository at this point in the history
Add stats to FXA calls #180
  • Loading branch information
jaredlockhart committed May 3, 2016
2 parents b3d9b28 + 032b7b8 commit eecf840
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions leaderboard/fxa/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from django.core.urlresolvers import reverse
from django.conf import settings

from leaderboard.stats import stats_client


def get_fxa_login_url(base_url):
"""
Expand Down Expand Up @@ -119,8 +121,10 @@ def refresh_authorization_token(self, refresh_token):
'refresh_token': refresh_token,
}

token_url = urlparse.urljoin(settings.FXA_OAUTH_URI, 'v1/token')
response = requests.post(token_url, data=json.dumps(params))
with stats_client.timer('fxa_refresh_auth_token_timing'):
token_url = urlparse.urljoin(settings.FXA_OAUTH_URI, 'v1/token')
response = requests.post(token_url, data=json.dumps(params))
stats_client.incr('fxa_refresh_auth_token_count')

return self._parse_response(response)

Expand All @@ -137,11 +141,13 @@ def verify_token(self, access_token):
"email": "foo@example.com"
}
"""
profile_url = urlparse.urljoin(settings.FXA_OAUTH_URI, 'v1/verify')
response = requests.post(
profile_url,
{'token': access_token},
)
with stats_client.timer('fxa_verify_auth_token_timing'):
profile_url = urlparse.urljoin(settings.FXA_OAUTH_URI, 'v1/verify')
response = requests.post(
profile_url,
{'token': access_token},
)
stats_client.incr('fxa_verify_auth_token_count')

return self._parse_response(response)

Expand All @@ -160,7 +166,10 @@ def get_profile_data(self, access_token):
'Authorization': 'Bearer {}'.format(access_token),
}

profile_url = urlparse.urljoin(settings.FXA_PROFILE_URI, 'v1/profile')
response = requests.get(profile_url, headers=headers)
with stats_client.timer('fxa_get_profile_timing'):
profile_url = urlparse.urljoin(
settings.FXA_PROFILE_URI, 'v1/profile')
response = requests.get(profile_url, headers=headers)
stats_client.incr('fxa_get_profile_count')

return self._parse_response(response)

0 comments on commit eecf840

Please sign in to comment.