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

Unified Diff: systrace/systrace/tracing_controller.py

Issue 2276263003: Pass in custom options to Systrace agents (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Rebase Created 4 years, 4 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
Index: systrace/systrace/tracing_controller.py
diff --git a/systrace/systrace/tracing_controller.py b/systrace/systrace/tracing_controller.py
index 5b1a0807f7eaebc52d22012666f50c03113dc9f3..708bdf12e176ef738e7a59001695d8ee1cb06f01 100644
--- a/systrace/systrace/tracing_controller.py
+++ b/systrace/systrace/tracing_controller.py
@@ -39,15 +39,14 @@ class TracingControllerAgent(tracing_agents.TracingAgent):
self._log_path = None
@py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
- def StartAgentTracing(self, options, categories, timeout=None):
+ def StartAgentTracing(self, config, timeout=None):
"""Start tracing for the controller tracing agent.
Start tracing for the controller tracing agent. Note that
the tracing controller records the "controller side"
of the clock sync records, and nothing else.
"""
- del options
- del categories
+ del config
if not trace_event.trace_can_enable():
raise RuntimeError, ('Cannot enable trace_event;'
' ensure py_utils is in PYTHONPATH')
@@ -94,21 +93,21 @@ class TracingControllerAgent(tracing_agents.TracingAgent):
raise NotImplementedError
class TracingController(object):
- def __init__(self, options, categories, agents):
+ def __init__(self, agents_with_config, controller_config):
"""Create tracing controller.
Create a tracing controller object. Note that the tracing
controller is also a tracing agent.
Args:
- options: Tracing options.
- categories: Categories of trace events to record.
- agents: List of tracing agents for this controller.
+ agents_with_config: List of tracing agents for this controller with the
+ corresponding tracing configuration objects.
+ controller_config: Configuration options for the tracing controller.
"""
- self._child_agents = agents
+ self._child_agents = None
+ self._child_agents_with_config = agents_with_config
self._controller_agent = TracingControllerAgent()
- self._options = options
- self._categories = categories
+ self._controller_config = controller_config
self._trace_in_progress = False
self.all_results = None
@@ -129,28 +128,28 @@ class TracingController(object):
# Start the controller tracing agents. Controller tracing agent
# must be started successfully to proceed.
if not self._controller_agent.StartAgentTracing(
- self._options,
- self._categories,
- timeout=self._options.timeout):
+ self._controller_config,
+ timeout=self._controller_config.timeout):
print 'Unable to start controller tracing agent.'
return False
# Start the child tracing agents.
succ_agents = []
- for agent in self._child_agents:
- if agent.StartAgentTracing(self._options,
- self._categories,
- timeout=self._options.timeout):
+ for agent_and_config in self._child_agents_with_config:
+ agent = agent_and_config.agent
+ config = agent_and_config.config
+ if agent.StartAgentTracing(config,
+ timeout=self._controller_config.timeout):
succ_agents.append(agent)
else:
print 'Agent %s not started.' % str(agent)
# Print warning if all agents not started.
- na = len(self._child_agents)
+ na = len(self._child_agents_with_config)
ns = len(succ_agents)
if ns < na:
print 'Warning: Only %d of %d tracing agents started.' % (ns, na)
- self._child_agents = succ_agents
+ self._child_agents = succ_agents
return True
def StopTracing(self):
@@ -171,7 +170,7 @@ class TracingController(object):
self._IssueClockSyncMarker()
succ_agents = []
for agent in self._child_agents:
- if agent.StopAgentTracing(timeout=self._options.timeout):
+ if agent.StopAgentTracing(timeout=self._controller_config.timeout):
succ_agents.append(agent)
else:
print 'Agent %s not stopped.' % str(agent)
@@ -179,7 +178,7 @@ class TracingController(object):
# Stop the controller tracing agent. Controller tracing agent
# must be stopped successfully to proceed.
if not self._controller_agent.StopAgentTracing(
- timeout=self._options.timeout):
+ timeout=self._controller_config.timeout):
print 'Unable to stop controller tracing agent.'
return False
@@ -194,7 +193,8 @@ class TracingController(object):
all_results = []
for agent in self._child_agents + [self._controller_agent]:
try:
- result = agent.GetResults(timeout=self._options.collection_timeout)
+ result = agent.GetResults(
+ timeout=self._controller_config.collection_timeout)
if not result:
print 'Warning: Timeout when getting results from %s.' % str(agent)
continue

Powered by Google App Engine
This is Rietveld 408576698