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

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

Issue 2708113002: Revert of Add field_specs to all metrics in luci-py (Closed)
Patch Set: 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 'Current count of the number of instances.', 29 description='Current count of the number of instances.',
30 [gae_ts_mon.StringField('instance_template')]
31 ), 30 ),
32 } 31 }
33 32
34 33
35 config_valid = gae_ts_mon.BooleanMetric( 34 config_valid = gae_ts_mon.BooleanMetric(
36 'machine_provider/gce_backend/config/valid', 35 'machine_provider/gce_backend/config/valid',
37 'Whether or not the current config is valid.', 36 description='Whether or not the current config is valid.',
38 [gae_ts_mon.StringField('config')],
39 ) 37 )
40 38
41 39
42 def compute_global_metrics(): # pragma: no cover 40 def compute_global_metrics(): # pragma: no cover
43 for name, count in instance_group_managers.count_instances().iteritems(): 41 for name, count in instance_group_managers.count_instances().iteritems():
44 logging.info('%s: %s', name, count) 42 logging.info('%s: %s', name, count)
45 GLOBAL_METRICS['instances'].set( 43 GLOBAL_METRICS['instances'].set(
46 count, 44 count,
47 fields={ 45 fields={
48 'instance_template': name, 46 'instance_template': name,
(...skipping 14 matching lines...) Expand all
63 Args: 61 Args:
64 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState. 62 state: gae_event_mon.ChromeInfraEvent.GCEBackendMachineState.
65 hostname: Name of the GCE instance this event is for. 63 hostname: Name of the GCE instance this event is for.
66 """ 64 """
67 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state) 65 state = gae_event_mon.MachineProviderEvent.GCEBackendMachineState.Value(state)
68 event = gae_event_mon.Event('POINT') 66 event = gae_event_mon.Event('POINT')
69 event.proto.event_source.host_name = hostname 67 event.proto.event_source.host_name = hostname
70 event.proto.machine_provider_event.gce_backend_state = state 68 event.proto.machine_provider_event.gce_backend_state = state
71 logging.info('Sending event: %s', event.proto) 69 logging.info('Sending event: %s', event.proto)
72 event.send() 70 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