fix: cheaper log time function - #1305
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes the base Pino logger timestamp function from ISO formatting to epoch time to reduce per-log allocation/formatting overhead, aligning with Pino’s default timestamp behavior while keeping the choice explicit in code.
Changes:
- Switch
baseLoggertimestamp frompino.stdTimeFunctions.isoTimetopino.stdTimeFunctions.epochTime.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
LGTM — trivial one-line perf change swapping pino's isoTime for epochTime timestamp function.
Extended reasoning...
Overview
The PR changes a single line in src/internal/monitoring/logger.ts, switching the pino timestamp option from pino.stdTimeFunctions.isoTime to pino.stdTimeFunctions.epochTime (pino's default). This avoids a Date allocation and ISO string formatting on every log line, since logs are normalized by Logflare downstream anyway.
Security risks
None. This only changes the format of the timestamp field embedded in structured logs; it does not touch auth, redaction, header allow-listing, or any other security-sensitive logic in this file.
Level of scrutiny
Very low. This is a mechanical, well-scoped one-line config swap using a built-in pino function, with an isolated blast radius (log timestamp formatting only). No behavioral change to request handling, serialization, or redaction logic.
Other factors
I checked the existing test mock in logger.test.ts, which still only stubs pino.stdTimeFunctions.isoTime. Since the mocked pino factory doesn't actually invoke the timestamp function, accessing the now-unstubbed epochTime just resolves to undefined and is passed through inertly — this doesn't cause test failures, just a stale/cosmetic mismatch in the mock, not worth blocking on.
Coverage Report for CI Build 31174343684Coverage remained the same at 80.602%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
b467eca to
51f9aa5
Compare
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Using isoTime in logger provides some readability in stdout logs. Otherwise, it's always normalized by logflare. In production environment, it nearly does nothing but does allocation of date and formatting per log.
What is the new behavior?
Use epochTime (pino default).
Keeping the explicit form communicates the decision better.
Additional context
This is a free win for heavy logging.