mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-18 08:02:31 -05:00
Only record the statsd timing on success.
This commit is contained in:
@@ -13,6 +13,12 @@ def statsd(namespace):
|
|||||||
try:
|
try:
|
||||||
res = func(*args, **kwargs)
|
res = func(*args, **kwargs)
|
||||||
elapsed_time = monotonic() - start_time
|
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:
|
except Exception as e:
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
@@ -27,12 +33,6 @@ def statsd(namespace):
|
|||||||
namespace=namespace, func=func.__name__, time="{0:.4f}".format(elapsed_time)
|
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
|
return res
|
||||||
wrapper.__wrapped__.__name__ = func.__name__
|
wrapper.__wrapped__.__name__ = func.__name__
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user