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

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

Issue 2705273003: Roll infra_libs and gae_ts_mon in luci-py, and add field_specs to all metrics (Closed)
Patch Set: Rebase Created 3 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 | « 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 config 12 import config
13 import instance_group_managers 13 import instance_group_managers
14 14
15 15
16 # Overrides to create app-global metrics. 16 # Overrides to create app-global metrics.
17 GLOBAL_TARGET_FIELDS = { 17 GLOBAL_TARGET_FIELDS = {
18 # Name of the module reporting the metric. 18 # Name of the module reporting the metric.
19 'job_name': '', 19 'job_name': '',
20 # Version of the app reporting the metric. 20 # Version of the app reporting the metric.
21 'hostname': '', 21 'hostname': '',
22 # ID of the instance reporting the metric. 22 # ID of the instance reporting the metric.
23 'task_num': 0, 23 'task_num': 0,
24 } 24 }
25 25
26 26
27 GLOBAL_METRICS = { 27 GLOBAL_METRICS = {
28 'config_max_instances': gae_ts_mon.GaugeMetric( 28 'config_max_instances': gae_ts_mon.GaugeMetric(
29 'machine_provider/gce_backend/config/instances/max', 29 'machine_provider/gce_backend/config/instances/max',
30 description='Maximum number of instances currently configured.', 30 'Maximum number of instances currently configured.',
31 [gae_ts_mon.StringField('instance_template')]
31 ), 32 ),
32 'config_min_instances': gae_ts_mon.GaugeMetric( 33 'config_min_instances': gae_ts_mon.GaugeMetric(
33 'machine_provider/gce_backend/config/instances/min', 34 'machine_provider/gce_backend/config/instances/min',
34 description='Minimum number of instances currently configured.', 35 'Minimum number of instances currently configured.',
36 [gae_ts_mon.StringField('instance_template')]
35 ), 37 ),
36 'instances': gae_ts_mon.GaugeMetric( 38 'instances': gae_ts_mon.GaugeMetric(
37 'machine_provider/gce_backend/instances', 39 'machine_provider/gce_backend/instances',
38 description='Current count of the number of instances.', 40 'Current count of the number of instances.',
41 [gae_ts_mon.StringField('instance_template')]
39 ), 42 ),
40 } 43 }
41 44
42 45
43 config_valid = gae_ts_mon.BooleanMetric( 46 config_valid = gae_ts_mon.BooleanMetric(
44 'machine_provider/gce_backend/config/valid', 47 'machine_provider/gce_backend/config/valid',
45 description='Whether or not the current config is valid.', 48 'Whether or not the current config is valid.',
49 [gae_ts_mon.StringField('config')],
46 ) 50 )
47 51
48 52
49 def compute_global_metrics(): # pragma: no cover 53 def compute_global_metrics(): # pragma: no cover
50 for name, counts in config.count_instances().iteritems(): 54 for name, counts in config.count_instances().iteritems():
51 logging.info('%s min: %s', name, counts[0]) 55 logging.info('%s min: %s', name, counts[0])
52 GLOBAL_METRICS['config_min_instances'].set( 56 GLOBAL_METRICS['config_min_instances'].set(
53 counts[0], 57 counts[0],
54 fields={ 58 fields={
55 'instance_template': name, 59 'instance_template': name,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 Args: 92 Args:
89 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState. 93 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState.
90 hostname: Name of the GCE instance this event is for. 94 hostname: Name of the GCE instance this event is for.
91 """ 95 """
92 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state) 96 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state)
93 event = gae_event_mon.Event('POINT') 97 event = gae_event_mon.Event('POINT')
94 event.proto.event_source.host_name = hostname 98 event.proto.event_source.host_name = hostname
95 event.proto.machine_provider_event.gce_backend_state = state 99 event.proto.machine_provider_event.gce_backend_state = state
96 logging.info('Sending event: %s', event.proto) 100 logging.info('Sending event: %s', event.proto)
97 event.send() 101 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