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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from infra_libs.ts_mon.common import metrics 5 from infra_libs.ts_mon.common import metrics
6 6
7 7
8 # Extending HTTP status codes to client-side errors and timeouts. 8 # Extending HTTP status codes to client-side errors and timeouts.
9 STATUS_OK = 200 9 STATUS_OK = 200
10 STATUS_ERROR = 901 10 STATUS_ERROR = 901
(...skipping 16 matching lines...) Expand all
27 'http/server_request_bytes', 27 'http/server_request_bytes',
28 description='Bytes received per http request (body only).') 28 description='Bytes received per http request (body only).')
29 server_response_bytes = metrics.CumulativeDistributionMetric( 29 server_response_bytes = metrics.CumulativeDistributionMetric(
30 'http/server_response_bytes', 30 'http/server_response_bytes',
31 description='Bytes sent per http request (content only).') 31 description='Bytes sent per http request (content only).')
32 server_durations = metrics.CumulativeDistributionMetric('http/server_durations', 32 server_durations = metrics.CumulativeDistributionMetric('http/server_durations',
33 description='Time elapsed between receiving a request and sending a' 33 description='Time elapsed between receiving a request and sending a'
34 ' response (including parsing) in milliseconds.') 34 ' response (including parsing) in milliseconds.')
35 server_response_status = metrics.CounterMetric('http/server_response_status', 35 server_response_status = metrics.CounterMetric('http/server_response_status',
36 description='Number of responses sent by HTTP status code.') 36 description='Number of responses sent by HTTP status code.')
37
38
39 def update_http_server_metrics(endpoint_name, response_status_code, elapsed_ms,
40 request_size=None, response_size=None,
41 user_agent=None):
42 fields = {'status': response_status_code, 'name': endpoint_name,
43 'is_robot': False}
44 if user_agent is not None:
45 # We must not log user agents, but we can store whether or not the
46 # user agent string indicates that the requester was a Google bot.
47 fields['is_robot'] = (
48 'GoogleBot' in user_agent or
49 'GoogleSecurityScanner' in user_agent or
50 user_agent == 'B3M/prober')
51
52 server_durations.add(elapsed_ms, fields=fields)
53 server_response_status.increment(fields=fields)
54 if request_size is not None:
55 server_request_bytes.add(request_size, fields=fields)
56 if response_size is not None:
57 server_response_bytes.add(response_size, fields=fields)
OLDNEW
« 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