fix: timestamp format in logs#205
Conversation
|
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. |
|
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. |
| _DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" | ||
| _DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S" |
There was a problem hiding this comment.
Is this used by any other code? I nothing else is using it we can just append .%f here.
There was a problem hiding this comment.
I think it would be safer to leave that string and just use another format string in the formatTime override
I agree, can we consider that in a major version change? |
bd81f21 to
e9520b3
Compare
This is done to support millisecond precision timestamp in the structured logs in cloudwatch as requested in #156. Changing directly to millisecond is a potentially breaking change, so we agreed on supporting this environmental variable on this version of the RIC. We'll remove the support in RIC v5, defaulting to milisecond.
|
Did some manual integration tests for that. Here the results. |
Issue #, if available:
#156
Description of changes:
Adds opt-in millisecond timestamp precision for JSON structured logs. When
AWS_LAMBDA_LOG_TIMESTAMP_PRECISION=millisecondsis set, timestamps are formatted as2024-06-19T23:13:05.068Zinstead of the default2024-06-19T23:13:05Z.Key changes:
_format_timestamp()function used by bothJsonFormatterandbootstrap.pyerror logging, ensuring consistent output.demo/) for end-to-end validation.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.