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

Side by Side Diff: appengine/swarming/event_mon_metrics.py

Issue 2584663002: swarming: send task tags to event_mon (Closed)
Patch Set: fixes Created 4 years 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 | no next file » | 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 import logging 5 import logging
6 import time 6 import time
7 7
8 import gae_event_mon 8 import gae_event_mon
9 9
10 from server import task_result 10 from server import task_result
11 11
12 12
13 DIMENSIONS = ( 13 DIMENSIONS = (
14 ('cores', int), 14 ('cores', int),
15 ('cpu', unicode), 15 ('cpu', unicode),
16 ('device_os', unicode), 16 ('device_os', unicode),
17 ('device_type', unicode), 17 ('device_type', unicode),
18 ('gpu', unicode), 18 ('gpu', unicode),
19 ('hidpi', unicode), 19 ('hidpi', unicode),
20 ('machine_type', unicode), 20 ('machine_type', unicode),
21 ('os', unicode), 21 ('os', unicode),
22 ('pool', unicode), 22 ('pool', unicode),
23 ('xcode_version', unicode), 23 ('xcode_version', unicode),
24 ('zone', unicode), 24 ('zone', unicode),
25 ) 25 )
26 26
27 27
28 TAGS = {
29 'build_id': ['buildnumber'],
30 'buildername': ['buildername'],
31 'codereview': ['rietveld'],
32 'master': ['master'],
33 'name': ['name'],
34 'patch_project': ['patch_project'],
35 'project': ['project'],
36 'purpose': ['purpose'],
37 'slavename': ['slavename'],
38 'stepname': ['stepname'],
39 }
40
41
28 def _to_timestamp(dt): 42 def _to_timestamp(dt):
29 return int(time.mktime(dt.timetuple())) 43 return int(time.mktime(dt.timetuple()))
30 44
31 45
32 def _files_ref_to_proto(files_ref, proto): 46 def _files_ref_to_proto(files_ref, proto):
33 if files_ref.isolated: 47 if files_ref.isolated:
34 proto.isolated = files_ref.isolated 48 proto.isolated = files_ref.isolated
35 if files_ref.isolatedserver: 49 if files_ref.isolatedserver:
36 proto.isolatedserver = files_ref.isolatedserver 50 proto.isolatedserver = files_ref.isolatedserver
37 if files_ref.namespace: 51 if files_ref.namespace:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 _files_ref_to_proto( 147 _files_ref_to_proto(
134 summary.outputs_ref, event.proto.swarming_task_event.outputs_ref) 148 summary.outputs_ref, event.proto.swarming_task_event.outputs_ref)
135 149
136 event.proto.swarming_task_event.cost_usd = summary.cost_usd 150 event.proto.swarming_task_event.cost_usd = summary.cost_usd
137 if summary.cost_saved_usd: 151 if summary.cost_saved_usd:
138 event.proto.swarming_task_event.cost_saved_usd = summary.cost_saved_usd 152 event.proto.swarming_task_event.cost_saved_usd = summary.cost_saved_usd
139 if summary.deduped_from: 153 if summary.deduped_from:
140 event.proto.swarming_task_event.deduped_from = summary.deduped_from 154 event.proto.swarming_task_event.deduped_from = summary.deduped_from
141 event.proto.swarming_task_event.try_number = summary.try_number 155 event.proto.swarming_task_event.try_number = summary.try_number
142 156
157 for tag in summary.tags:
158 if ':' not in tag:
159 logging.error('Unexpected tag: %r', tag)
160 continue
161 name, value = tag.split(':', 1)
162 for event_tag, task_tags in TAGS.iteritems():
163 if name in task_tags:
164 getattr(event.proto.swarming_task_event.tags, event_tag).append(value)
165
143 166
144 def initialize(): 167 def initialize():
145 gae_event_mon.initialize('swarming') 168 gae_event_mon.initialize('swarming')
146 169
147 170
148 def send_task_event(summary): 171 def send_task_event(summary):
149 """Sends an event_mon event about a swarming task. 172 """Sends an event_mon event about a swarming task.
150 173
151 Currently implemented as sending a HTTP request. 174 Currently implemented as sending a HTTP request.
152 175
153 Args: 176 Args:
154 summary: TaskResultSummary object. 177 summary: TaskResultSummary object.
155 """ 178 """
156 # Isolate rest of the app from monitoring pipeline issues. They should 179 # Isolate rest of the app from monitoring pipeline issues. They should
157 # not cause outage of swarming. 180 # not cause outage of swarming.
158 try: 181 try:
159 event = gae_event_mon.Event('POINT') 182 event = gae_event_mon.Event('POINT')
160 _task_summary_to_proto(summary, event) 183 _task_summary_to_proto(summary, event)
161 event.send() 184 event.send()
162 except Exception: 185 except Exception:
163 logging.exception('Caught exception while sending event') 186 logging.exception('Caught exception while sending event')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698