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

Unified 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, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/event_mon/config.py
diff --git a/infra_libs/event_mon/config.py b/infra_libs/event_mon/config.py
index df898d3afb9ed83fdb1ec0bd342485325b919bc5..ccdd6a445bfe6d3c7690d47a922e5ed9f0fd13fd 100644
--- a/infra_libs/event_mon/config.py
+++ b/infra_libs/event_mon/config.py
@@ -165,6 +165,23 @@ def setup_monitoring(run_type='dry',
dry_run=dry_run)
+def set_default_event(event):
+ """Change the default ChromeInfraEvent used to compute all events.
+
+ Args:
+ event (ChromeInfraEvent): default event
+ """
+ # Here we raise an exception because failing to set the default event
+ # could lead to invalid data in the database.
+ if not isinstance(event, ChromeInfraEvent):
+ msg = ('A ChromeInfraEvent is required as the default event. Got %s' %
+ type(event))
+ logging.error(msg)
+ raise TypeError(msg)
+
+ _cache['default_event'] = event
+
+
def close():
"""Reset the state.
« 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