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

Unified Diff: infra_libs/ts_mon/common/http_metrics.py

Issue 1797103003: gae_ts_mon: instrument Cloud Endpoint methods (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Reduced test flakiness 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 | « appengine_module/gae_ts_mon/test/config_test.py ('k') | infra_libs/ts_mon/common/interface.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/ts_mon/common/http_metrics.py
diff --git a/infra_libs/ts_mon/common/http_metrics.py b/infra_libs/ts_mon/common/http_metrics.py
index d90260eb7671a193cb50d05416dcb3a5f79e4deb..0df4faca68f8d592f23c0a964f7378e5f9f88417 100644
--- a/infra_libs/ts_mon/common/http_metrics.py
+++ b/infra_libs/ts_mon/common/http_metrics.py
@@ -34,3 +34,24 @@ server_durations = metrics.CumulativeDistributionMetric('http/server_durations',
' response (including parsing) in milliseconds.')
server_response_status = metrics.CounterMetric('http/server_response_status',
description='Number of responses sent by HTTP status code.')
+
+
+def update_http_server_metrics(endpoint_name, response_status_code, elapsed_ms,
+ request_size=None, response_size=None,
+ user_agent=None):
+ fields = {'status': response_status_code, 'name': endpoint_name,
+ 'is_robot': False}
+ if user_agent is not None:
+ # We must not log user agents, but we can store whether or not the
+ # user agent string indicates that the requester was a Google bot.
+ fields['is_robot'] = (
+ 'GoogleBot' in user_agent or
+ 'GoogleSecurityScanner' in user_agent or
+ user_agent == 'B3M/prober')
+
+ server_durations.add(elapsed_ms, fields=fields)
+ server_response_status.increment(fields=fields)
+ if request_size is not None:
+ server_request_bytes.add(request_size, fields=fields)
+ if response_size is not None:
+ server_response_bytes.add(response_size, fields=fields)
« no previous file with comments | « appengine_module/gae_ts_mon/test/config_test.py ('k') | infra_libs/ts_mon/common/interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698