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

Unified Diff: systrace/systrace/tracing_controller.py

Issue 2712163002: [Systrace] Fix systrace clock syncing issue with BattOr. (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 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 e6f4d6dae14ef2e8121d70fda33e4ebfe2dcea8c..879ed4d9b9c900bfc1d3edd8c3cb60a57b53e95a 100644
--- a/systrace/systrace/tracing_controller.py
+++ b/systrace/systrace/tracing_controller.py
@@ -19,6 +19,7 @@ from systrace import trace_result
from systrace import tracing_agents
from py_trace_event import trace_event
+from telemetry.timeline import trace_data
TRACE_DATA_CONTROLLER_NAME = 'systraceController'
@@ -68,6 +69,18 @@ class TracingControllerAgent(tracing_agents.TracingAgent):
return True
@py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT)
+ def CollectAgentTraceData(self, trace_data_builder):
+ assert not trace_event.trace_is_enabled(), 'Stop tracing before collection.'
+ with open(self._log_path, 'r') as fp:
+ data = ast.literal_eval(fp.read() + ']')
+ trace_data_builder.AddTraceFor(trace_data.TELEMETRY_PART, {
+ 'traceEvents': data,
+ 'metadata': {
+ 'clock-domain': 'TELEMETRY',
+ }
+ })
+
+ @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT)
def GetResults(self, timeout=None):
"""Gets the log output from the controller tracing agent.
@@ -104,6 +117,7 @@ class TracingController(object):
corresponding tracing configuration objects.
controller_config: Configuration options for the tracing controller.
"""
+ self.builder = trace_data.TraceDataBuilder()
self._child_agents = None
self._child_agents_with_config = agents_with_config
self._controller_agent = TracingControllerAgent()
@@ -194,18 +208,9 @@ class TracingController(object):
self._child_agents = succ_agents
# Collect the results from all the stopped tracing agents.
- all_results = []
for agent in self._child_agents + [self._controller_agent]:
try:
- result = agent.GetResults(
- timeout=self._controller_config.collection_timeout)
- if not result:
- print 'Warning: Timeout when getting results from %s.' % str(agent)
- continue
- if result.source_name in [r.source_name for r in all_results]:
- print ('Warning: Duplicate tracing agents named %s.' %
- result.source_name)
- all_results.append(result)
+ agent.CollectAgentTraceData(self.builder)
# Check for exceptions. If any exceptions are seen, reraise and abort.
# Note that a timeout exception will be swalloed by the timeout
# mechanism and will not get to that point (it will return False instead
@@ -214,8 +219,8 @@ class TracingController(object):
print 'Warning: Exception getting results from %s:' % str(agent)
print sys.exc_info()[0]
raise
- self.all_results = all_results
- return all_results
+ self.all_results = self.builder.AsData()
+ return self.all_results
def GetTraceType(self):
"""Return a string representing the child agents that are being traced."""

Powered by Google App Engine
This is Rietveld 408576698