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

Side by Side Diff: infra_libs/event_mon/config.py

Issue 1407143009: Added event_mon.set_default_event (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: set_default_event raises exception Created 5 years, 1 month 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 | « infra_libs/event_mon/__init__.py ('k') | infra_libs/event_mon/test/config_test.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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import socket 6 import socket
7 7
8 import infra_libs 8 import infra_libs
9 from infra_libs.event_mon.protos.chrome_infra_log_pb2 import ( 9 from infra_libs.event_mon.protos.chrome_infra_log_pb2 import (
10 ChromeInfraEvent, ServiceEvent) 10 ChromeInfraEvent, ServiceEvent)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 _router = ev_router._TextStreamRouter() 158 _router = ev_router._TextStreamRouter()
159 elif run_type == 'file': 159 elif run_type == 'file':
160 _router = ev_router._LocalFileRouter(output_file, 160 _router = ev_router._LocalFileRouter(output_file,
161 dry_run=dry_run) 161 dry_run=dry_run)
162 else: 162 else:
163 _router = ev_router._HttpRouter(_cache, 163 _router = ev_router._HttpRouter(_cache,
164 ENDPOINTS.get(run_type), 164 ENDPOINTS.get(run_type),
165 dry_run=dry_run) 165 dry_run=dry_run)
166 166
167 167
168 def set_default_event(event):
169 """Change the default ChromeInfraEvent used to compute all events.
170
171 Args:
172 event (ChromeInfraEvent): default event
173 """
174 # Here we raise an exception because failing to set the default event
175 # could lead to invalid data in the database.
176 if not isinstance(event, ChromeInfraEvent):
177 msg = ('A ChromeInfraEvent is required as the default event. Got %s' %
178 type(event))
179 logging.error(msg)
180 raise TypeError(msg)
181
182 _cache['default_event'] = event
183
184
168 def close(): 185 def close():
169 """Reset the state. 186 """Reset the state.
170 187
171 Call this right before exiting the program. 188 Call this right before exiting the program.
172 189
173 Returns: 190 Returns:
174 success (bool): False if an error occured 191 success (bool): False if an error occured
175 """ 192 """
176 global _router, _cache 193 global _router, _cache
177 _router = None 194 _router = None
178 _cache = {} 195 _cache = {}
179 return True 196 return True
OLDNEW
« no previous file with comments | « infra_libs/event_mon/__init__.py ('k') | infra_libs/event_mon/test/config_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698