Only record the statsd timing on success.

This commit is contained in:
Rebecca Law
2017-03-17 13:33:57 +00:00
parent f01760f6e6
commit 26576622b1

View File

@@ -13,6 +13,12 @@ def statsd(namespace):
try:
res = func(*args, **kwargs)
elapsed_time = monotonic() - start_time
statsd_client.incr('{namespace}.{func}'.format(
namespace=namespace, func=func.__name__)
)
statsd_client.timing('{namespace}.{func}'.format(
namespace=namespace, func=func.__name__), elapsed_time
)
except Exception as e:
current_app.logger.error(
@@ -27,12 +33,6 @@ def statsd(namespace):
namespace=namespace, func=func.__name__, time="{0:.4f}".format(elapsed_time)
)
)
statsd_client.incr('{namespace}.{func}'.format(
namespace=namespace, func=func.__name__)
)
statsd_client.timing('{namespace}.{func}'.format(
namespace=namespace, func=func.__name__), elapsed_time
)
return res
wrapper.__wrapped__.__name__ = func.__name__
return wrapper