-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix timestamp drift due to using instanceof typeguard #827
base: main
Are you sure you want to change the base?
Conversation
@@ -253,7 +253,7 @@ export class LoggingCommon { | |||
// metadata. As Winston 3 buffers logs when a transport (such as this one) | |||
// invokes its log callback asynchronously, a timestamp assigned at log time | |||
// is more accurate than one assigned in a transport. | |||
if (metadata.timestamp instanceof Date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This typeguard is preventing customer metadata timestamp to be properly assigned to entry metadata. Considering entryMetadata is expecting a union type Timestamp | null | undefined, I think it is not necessary for us to force a Date
type to be checked and assigned.
Can you add any tests around this? Try to make one that would fail before the change, but passes after |
Good suggestion. Will do! |
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #802 🦕
This is to fix timestamp drift issue which may cause timestamp inaccuracy while using OpenTelemetry and view trace timespans. Since timestamp within metadata is defined as a union-types including null and undefined, the type guard is not necessary here.