Skip to content

fix: timestamp format in logs#205

Open
maxday wants to merge 3 commits into
mainfrom
maxday/fix-156
Open

fix: timestamp format in logs#205
maxday wants to merge 3 commits into
mainfrom
maxday/fix-156

Conversation

@maxday

@maxday maxday commented Jun 12, 2026

Copy link
Copy Markdown
Member

Issue #, if available:
#156

Description of changes:

In awslambdaric/lambda_runtime_log_utils.py

  1. Changed _DATETIME_FORMAT to "%Y-%m-%dT%H:%M:%S" (removed trailing Z)
  2. Added formatTime() override that uses datetime.fromtimestamp(record.created, tz=timezone.utc) with %f (microseconds), truncated to 3 digits for milliseconds, with Z appended

This produces timestamps like 2024-06-19T23:13:05.068Z — matching the platform log format.

Testing:

Before
beforeFix

After
afterFix

Target (OCI, Managed Runtime, both):
Both

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@darklight3it

darklight3it commented Jun 17, 2026

Copy link
Copy Markdown

From experience this kind of changes can be very dangerous. For multiple reasons.

I'm not that worried about CloudWatch compatibility (we can always ask @luben for that)

Imagine a customer creating a script to analyze some logs and expecting a strict format, or worse blindly exporting the logs to another database with a strict schema.

My idea here is that we should opt-in the new format, so the customer won't be surprised by the change.

@darklight3it darklight3it self-requested a review June 17, 2026 16:15
@darklight3it

Copy link
Copy Markdown

Also I think this is also highlighting a design flaw. The RIC should not be concerned with the time format.

It should flush to the sink the biggest possible epoch and CW should do the conversion to human readable time.

Comment on lines -10 to +12
_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used by any other code? I nothing else is using it we can just append .%f here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants