Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1887)

Unified Diff: appengine_module/gae_ts_mon/config.py

Issue 1772913003: gae_ts_mon: flush metrics asynchronously (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine_module/gae_ts_mon/config.py
diff --git a/appengine_module/gae_ts_mon/config.py b/appengine_module/gae_ts_mon/config.py
index 8c31f6e73b73c29724f12a407981eca9cb12344e..2cbe0a344d95538c079dc8fba7c7c115efbdbbcf 100644
--- a/appengine_module/gae_ts_mon/config.py
+++ b/appengine_module/gae_ts_mon/config.py
@@ -171,6 +171,8 @@ def _instrumented_dispatcher(dispatcher, request, response, time_fn=time.time):
start_time = time_fn()
response_status = 0
interface.state.store.initialize_context()
+ flush_thread = threading.Thread(target=flush_metrics_if_needed)
+ flush_thread.start()
try:
ret = dispatcher(request, response)
except webapp2.HTTPException as ex:
@@ -184,6 +186,7 @@ def _instrumented_dispatcher(dispatcher, request, response, time_fn=time.time):
response = ret
response_status = response.status_int
finally:
+ flush_thread.join()
elapsed_ms = int((time_fn() - start_time) * 1000)
fields = {'status': response_status, 'name': '', 'is_robot': False}
@@ -206,8 +209,6 @@ def _instrumented_dispatcher(dispatcher, request, response, time_fn=time.time):
if response.content_length is not None: # pragma: no cover
http_metrics.server_response_bytes.add(response.content_length,
fields=fields)
- flush_metrics_if_needed()
-
return ret
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698