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

Side by Side Diff: appengine/gce-backend/metrics.py

Issue 2709453002: Add field_specs to all metrics in luci-py (Closed)
Patch Set: oops Created 3 years, 10 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 | « no previous file | appengine/machine_provider/metrics.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 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Metrics to track with ts_mon and event_mon.""" 5 """Metrics to track with ts_mon and event_mon."""
6 6
7 import logging 7 import logging
8 8
9 import gae_event_mon 9 import gae_event_mon
10 import gae_ts_mon 10 import gae_ts_mon
11 11
12 import instance_group_managers 12 import instance_group_managers
13 13
14 14
15 # Overrides to create app-global metrics. 15 # Overrides to create app-global metrics.
16 GLOBAL_TARGET_FIELDS = { 16 GLOBAL_TARGET_FIELDS = {
17 # Name of the module reporting the metric. 17 # Name of the module reporting the metric.
18 'job_name': '', 18 'job_name': '',
19 # Version of the app reporting the metric. 19 # Version of the app reporting the metric.
20 'hostname': '', 20 'hostname': '',
21 # ID of the instance reporting the metric. 21 # ID of the instance reporting the metric.
22 'task_num': 0, 22 'task_num': 0,
23 } 23 }
24 24
25 25
26 GLOBAL_METRICS = { 26 GLOBAL_METRICS = {
27 'instances': gae_ts_mon.GaugeMetric( 27 'instances': gae_ts_mon.GaugeMetric(
28 'machine_provider/gce_backend/instances', 28 'machine_provider/gce_backend/instances',
29 description='Current count of the number of instances.', 29 'Current count of the number of instances.',
30 [gae_ts_mon.StringField('instance_template')]
30 ), 31 ),
31 } 32 }
32 33
33 34
34 config_valid = gae_ts_mon.BooleanMetric( 35 config_valid = gae_ts_mon.BooleanMetric(
35 'machine_provider/gce_backend/config/valid', 36 'machine_provider/gce_backend/config/valid',
36 description='Whether or not the current config is valid.', 37 'Whether or not the current config is valid.',
38 [gae_ts_mon.StringField('config')],
37 ) 39 )
38 40
39 41
40 def compute_global_metrics(): # pragma: no cover 42 def compute_global_metrics(): # pragma: no cover
41 for name, count in instance_group_managers.count_instances().iteritems(): 43 for name, count in instance_group_managers.count_instances().iteritems():
42 logging.info('%s: %s', name, count) 44 logging.info('%s: %s', name, count)
43 GLOBAL_METRICS['instances'].set( 45 GLOBAL_METRICS['instances'].set(
44 count, 46 count,
45 fields={ 47 fields={
46 'instance_template': name, 48 'instance_template': name,
(...skipping 14 matching lines...) Expand all
61 Args: 63 Args:
62 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState. 64 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState.
63 hostname: Name of the GCE instance this event is for. 65 hostname: Name of the GCE instance this event is for.
64 """ 66 """
65 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state) 67 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state)
66 event = gae_event_mon.Event('POINT') 68 event = gae_event_mon.Event('POINT')
67 event.proto.event_source.host_name = hostname 69 event.proto.event_source.host_name = hostname
68 event.proto.machine_provider_event.gce_backend_state = state 70 event.proto.machine_provider_event.gce_backend_state = state
69 logging.info('Sending event: %s', event.proto) 71 logging.info('Sending event: %s', event.proto)
70 event.send() 72 event.send()
OLDNEW
« no previous file with comments | « no previous file | appengine/machine_provider/metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698