Skip to content

Commit 7ecf2db

Browse files
committed
More metrics
1 parent e5e02ed commit 7ecf2db

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

kmsauth/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def decrypt_token(self, username, token):
253253
version < self.minimum_token_version):
254254
raise TokenValidationError('Unacceptable token version.')
255255
if self.stats:
256+
self.stats.incr('token_version_{0}'.format(version))
256257
# Checkpoint 1: After username parsing
257258
checkpoint_1 = (datetime.datetime.utcnow() - time_start).total_seconds() * 1000 # noqa: E501
258259
self.stats.timing('checkpoint_1_after_parse', checkpoint_1) # noqa: E501
@@ -291,15 +292,29 @@ def decrypt_token(self, username, token):
291292
if len(self.TOKENS) >= self.token_cache_size:
292293
self.stats.incr('token_cache_eviction')
293294

295+
# Checkpoint 3.5: After stats calls in cache miss
296+
checkpoint_3_5 = (datetime.datetime.utcnow() - time_start).total_seconds() * 1000 # noqa: E501
297+
self.stats.timing('checkpoint_3_5_after_cache_miss_stats', checkpoint_3_5) # noqa: E501
298+
294299
try:
295300
token = base64.b64decode(token)
301+
if self.stats:
302+
# Checkpoint 3.7: After base64 decode
303+
checkpoint_3_7 = (datetime.datetime.utcnow() - time_start).total_seconds() * 1000 # noqa: E501
304+
self.stats.timing('checkpoint_3_7_after_base64_decode', checkpoint_3_7) # noqa: E501
305+
296306
# Ensure normal context fields override whatever is in
297307
# extra_context.
298308
context = copy.deepcopy(self.extra_context)
299309
context['to'] = self.to_auth_context
300310
context['from'] = _from
301311
if version > 1:
302312
context['user_type'] = user_type
313+
314+
if self.stats:
315+
# Checkpoint 3.9: After context setup
316+
checkpoint_3_9 = (datetime.datetime.utcnow() - time_start).total_seconds() * 1000 # noqa: E501
317+
self.stats.timing('checkpoint_3_9_after_context_setup', checkpoint_3_9) # noqa: E501
303318
if self.stats:
304319
with self.stats.timer('kms_decrypt_token'):
305320
data = self.kms_client.decrypt(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from setuptools import setup, find_packages
1515

16-
VERSION = "0.6.4.dev5"
16+
VERSION = "0.6.4.dev6"
1717

1818
requirements = [
1919
# Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK)

0 commit comments

Comments
 (0)