-
Notifications
You must be signed in to change notification settings - Fork 5
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
Change coordinator IDs to ISO8601 format #292
Conversation
@@ -56,7 +56,7 @@ export const callSignedApi = async (url: string, timeout: number): Promise<Signe | |||
}; | |||
|
|||
export const runDataFetcher = async () => { | |||
return logger.runWithContext({ dataFetcherCoordinatorId: Date.now().toString() }, async () => { | |||
return logger.runWithContext({ dataFetcherCoordinatorId: new Date().toISOString() }, async () => { |
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.
If we continue with time, I'd prefer timestamp rather than ISO string cuz it's easier to search logs with timestamp. When you double-click on timestamp it will select all, it's not possible with ISO format 😄
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.
:D UUID would have the same issue though.
Anyway, let's close this and stick with timestamp.
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.
The objective of switching to uuid
is not about the double-click, it guarantees that the uniqueness. And it doesn't have to be uuid
it can be 32-bit hex generated via node:crypto
library.
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.
Yeah, but the JS timestamp is in MS so that's very low probability that the loops start at the same time. Anyway, 32-bit hex from node:crypto + a timestamp logged at the start of the coordinator seems like a trade-off that everyone is going to be happy with. WDYT?
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.
Yes, it looks like sweet-spot.
99f35b3
to
bfe0894
Compare
9a82eec
to
f6bd930
Compare
@@ -83,7 +83,7 @@ export const runDataFetcher = async () => { | |||
|
|||
const urlCount = urls.length; | |||
const staggerTimeMs = signedDataFetchIntervalMs / urlCount; | |||
logger.info('Fetching signed data.', { urlCount, staggerTimeMs }); | |||
logger.info('Fetching signed data.', { urlCount, staggerTimeMs, currentTime: new Date().toISOString() }); |
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 message is logged as a basically the first thing, so I've logged the current time here instead of logging another message.
Closes #280
Rationale
This should make the IDs easy to differentiate from each other, while being "unique enough". I don't see a huge need for UUIDs.