Skip to content

Commit

Permalink
Fix timestamp parsing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
maddieford committed Jul 11, 2023
1 parent 603c90b commit c124cc8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests_e2e/tests/lib/agent_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ def from_dictionary(dictionary: Dict[str, str]):
@property
def timestamp(self) -> datetime:
# Extension logs may follow different timestamp formats
# 2023/07/10 20:50:13
ext_timestamp_regex_1 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}"
# 2023/07/10 20:50:13.459260
ext_timestamp_regex_2 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}[.\d]*"
ext_timestamp_regex_1 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}[.\d]+"
# 2023/07/10 20:50:13
ext_timestamp_regex_2 = r"\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}"

if re.match(ext_timestamp_regex_1, self.when):
return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S')
elif re.match(ext_timestamp_regex_2, self.when):
return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S.%f')
elif re.match(ext_timestamp_regex_2, self.when):
return datetime.strptime(self.when, u'%Y/%m/%d %H:%M:%S')
# Logs from agent follow this format: 2023-07-10T20:50:13.038599Z
return datetime.strptime(self.when, u'%Y-%m-%dT%H:%M:%S.%fZ')

Expand Down

0 comments on commit c124cc8

Please sign in to comment.