예제 #1
0
 def __call__(self, req):
     taskid = req.headers['X-Neutron-Profiler-taskid']
     action = req.headers['X-Neutron-Profiler-Action']
     if action == 'start':
         # (anilvenkata): save self.taskid, helpful in throwing error
         # if stop called without start
         GreenletProfiler.set_clock_type('cpu')
         GreenletProfiler.start()
         LOG.debug("Trace Profiler.start profiling %s ", os.getpid())
     elif action == 'stop':
         GreenletProfiler.stop()
         LOG.debug("Trace Profiler.stop profiling %s ", os.getpid())
         stats = GreenletProfiler.get_func_stats()
         trace_path = os.path.join(cfg.CONF.trace_profiler.trace_path,
                                   taskid)
         utils.ensure_dir(trace_path)
         trace_file = os.path.join(trace_path, str(os.getpid()))
         LOG.debug("Trace Profiler.writing to trace file %s ", trace_file)
         stats.save(trace_file, cfg.CONF.trace_profiler.trace_format)
         GreenletProfiler.clear_stats()
     else:
         LOG.info(
             "Invalid profiler action %(action)s with "
             " taskid %(taskid)s", {
                 "action": action,
                 "taskid": taskid
             })
예제 #2
0
 def test_ensure_dir_calls_makedirs(self, makedirs):
     file.ensure_dir("/etc/create/directory")
     makedirs.assert_called_once_with("/etc/create/directory", 0o755)
예제 #3
0
 def test_ensure_dir_no_fail_if_exists(self, makedirs):
     error = OSError()
     error.errno = errno.EEXIST
     makedirs.side_effect = error
     file.ensure_dir("/etc/create/concurrently")
예제 #4
0
 def test_ensure_dir_calls_makedirs(self, makedirs):
     file.ensure_dir("/etc/create/directory")
     makedirs.assert_called_once_with("/etc/create/directory", 0o755)
예제 #5
0
 def test_ensure_dir_no_fail_if_exists(self, makedirs):
     error = OSError()
     error.errno = errno.EEXIST
     makedirs.side_effect = error
     file.ensure_dir("/etc/create/concurrently")
예제 #6
0
 def get_profiler_sock_path(cls):
     utils.ensure_dir(cfg.CONF.trace_profiler.sock_path)
     return os.path.join(cfg.CONF.trace_profiler.sock_path,
                         str(os.getpid()))