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

Side by Side Diff: appengine_module/gae_ts_mon/README.md

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
OLDNEW
1 # Setting up timeseries monitoring on App Engine. 1 # Setting up timeseries monitoring on App Engine.
2 2
3 1. Symlink this directory into your appengine app. 3 1. Symlink this directory into your appengine app.
4 4
5 cd infra/appengine/myapp 5 cd infra/appengine/myapp
6 ln -s ../../appengine_module/gae_ts_mon . 6 ln -s ../../appengine_module/gae_ts_mon .
7 7
8 1. Add the scheduled task to your `cron.yaml` file. Create it if you don't 8 1. Add the scheduled task to your `cron.yaml` file. Create it if you don't
9 have one already. 9 have one already.
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 [...] 26 [...]
27 27
28 app = webapp2.WSGIApplication(my_handlers) 28 app = webapp2.WSGIApplication(my_handlers)
29 gae_ts_mon.initialize(app, cron_module='<cron_module_name>') 29 gae_ts_mon.initialize(app, cron_module='<cron_module_name>')
30 30
31 You must do this in every top-level request handler that's listed in your 31 You must do this in every top-level request handler that's listed in your
32 app.yaml to ensure metrics are registered no matter which type of request 32 app.yaml to ensure metrics are registered no matter which type of request
33 an instance receives first. 33 an instance receives first.
34 34
35 If your app does not contain a `webapp2.WSGIApplication` instance
36 (e.g. it's a Cloud Endpoints only app), then pass `None` as the
37 first argument to `gae_ts_mon.initialize`.
38
35 The `gae_ts_mon.initialize` method takes a few optional parameters: 39 The `gae_ts_mon.initialize` method takes a few optional parameters:
36 - `cron_module` (str, default='default'): if you specified a custom 40 - `cron_module` (str, default='default'): if you specified a custom
37 module for the cron job, you must specify it in every call to 41 module for the cron job, you must specify it in every call to
38 `initialize`. 42 `initialize`.
39 - `is_enabled_fn` (function with no arguments returning `bool`): 43 - `is_enabled_fn` (function with no arguments returning `bool`):
40 a callback to enable/disable sending the actual metrics. Default: `None` 44 a callback to enable/disable sending the actual metrics. Default: `None`
41 which is equivalent to `lambda: True`. The callback is called on every 45 which is equivalent to `lambda: True`. The callback is called on every
42 metrics flush, and takes effect immediately. Make sure the callback is 46 metrics flush, and takes effect immediately. Make sure the callback is
43 efficient, or it will slow down your requests. 47 efficient, or it will slow down your requests.
44 48
49 1. Instrument all Cloud Endpoint methods if you have any by adding a decorator:
50
51 @gae_ts_mon.instrument_endpoint()
52 @endpoints.method(...)
53 def your_method(self, request):
54 ...
55
45 1. Give your app's service account permission to send metrics to the API. You 56 1. Give your app's service account permission to send metrics to the API. You
46 can find the name of your service account on the `Permissions` page of your 57 can find the name of your service account on the `Permissions` page of your
47 project in the cloud console - it'll look something like 58 project in the cloud console - it'll look something like
48 `app-id@appspot.gserviceaccount.com`. Or search the default module's logs 59 `app-id@appspot.gserviceaccount.com`. Or search the default module's logs
49 for `"Initializing with service account"`. Add it as a "Publisher" of the 60 for `"Initializing with service account"`. Add it as a "Publisher" of the
50 "monacq" PubSub topic in the 61 "monacq" PubSub topic in the
51 [chrome-infra-mon-pubsub project](https://pantheon.corp.google.com/project/c hrome-infra-mon-pubsub/cloudpubsub/topicList) 62 [chrome-infra-mon-pubsub project](https://pantheon.corp.google.com/project/c hrome-infra-mon-pubsub/cloudpubsub/topicList)
52 by selecting it from the list and clicking "Permissions". If you see an 63 by selecting it from the list and clicking "Permissions". If you see an
53 error "You do not have viewing permissions for the selected resource.", then 64 error "You do not have viewing permissions for the selected resource.", then
54 please ask pgervais@chromium.org (AMER) or sergiyb@chromium.org (EMEA) to do 65 please ask pgervais@chromium.org (AMER) or sergiyb@chromium.org (EMEA) to do
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 only one instance will be running it at a time. A global metric is 134 only one instance will be running it at a time. A global metric is
124 then cleared the moment it is sent. Thus, global metrics will be sent 135 then cleared the moment it is sent. Thus, global metrics will be sent
125 at the correct intervals, regardless of the number of instances the 136 at the correct intervals, regardless of the number of instances the
126 app is currently running. 137 app is currently running.
127 138
128 Note also the use of `target_fields` parameter: it overrides the 139 Note also the use of `target_fields` parameter: it overrides the
129 default target fields which would otherwise distinguish the metric per 140 default target fields which would otherwise distinguish the metric per
130 module, version, or instance ID. Using `target_fields` in regular, 141 module, version, or instance ID. Using `target_fields` in regular,
131 "local" metrics is not allowed, as it would result in errors on the 142 "local" metrics is not allowed, as it would result in errors on the
132 monitoring endpoint, and loss of data. 143 monitoring endpoint, and loss of data.
OLDNEW
« no previous file with comments | « appengine/chromium_try_flakes/status/test/cq_status_test.py ('k') | appengine_module/gae_ts_mon/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698