From 925d99d7d9d2543ba017b01ccade7bda1db8907f Mon Sep 17 00:00:00 2001 From: Pierre Marieu Date: Tue, 16 Feb 2021 11:43:56 +0000 Subject: [PATCH] Fix timestamp bug in file reporter The file reporter writes the profile into a local file, current timestamp is added in the file name, unfortunately that timestamp was set at load time because of the default argument so each reports would always go into the same file. This small fix will ensure that different files will be created and the file name will get proper timestamp. --- codeguru_profiler_agent/file_reporter/file_reporter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codeguru_profiler_agent/file_reporter/file_reporter.py b/codeguru_profiler_agent/file_reporter/file_reporter.py index d9c58c0..86a382b 100644 --- a/codeguru_profiler_agent/file_reporter/file_reporter.py +++ b/codeguru_profiler_agent/file_reporter/file_reporter.py @@ -35,7 +35,9 @@ def refresh_configuration(self): """ pass - def report(self, profile, agent_metadata=None, timestamp=datetime.datetime.now()): + def report(self, profile, agent_metadata=None, timestamp=None): + if timestamp is None: + timestamp = datetime.datetime.now() output_filename = self._output_filename_for(timestamp) logger.info("Writing profile to '{}'".format(output_filename))